Python和Matplotlib条形图输出图例中的奇怪框

Python和Matplotlib条形图输出图例中的奇怪框,python,matplotlib,sqlite,legend,Python,Matplotlib,Sqlite,Legend,我或多或少是个业余程序员,发现python和matplotlib可以创建一些不错的输出。 我试图分析逗号分隔的输出和显示数据。 我能够将文本文件中的数据输入sqlite3和 我使用sqlite3执行一些求和和和排序,但是输出中有一个框。 我的输出有灵活的数据 {所以我不知道我有多少列,所以我通过反复试验发现,如果我预先定义颜色,它只会重复它们。不太相关} 例如,数据是: 错误11000 错误2,5000 错误34000 错误4,3000 我就快到了,我有一个小小的白色盒子,就像我传说中的一个复选

我或多或少是个业余程序员,发现python和matplotlib可以创建一些不错的输出。 我试图分析逗号分隔的输出和显示数据。 我能够将文本文件中的数据输入sqlite3和 我使用sqlite3执行一些求和和和排序,但是输出中有一个框。 我的输出有灵活的数据

{所以我不知道我有多少列,所以我通过反复试验发现,如果我预先定义颜色,它只会重复它们。不太相关}

例如,数据是:

错误11000 错误2,5000 错误34000 错误4,3000

我就快到了,我有一个小小的白色盒子,就像我传说中的一个复选框 我在哪里显示error 1..error 4,我无法确定它来自哪里

我试过了,但不管用。 我想我真的不应该这样做,因为我不知道我在做什么

import numpy as np
import pylab as pl
import sqlite3

values = []
strlegend = []

db_filename = 'test.sqlite'

conn = sqlite3.connect(db_filename)
cursor = conn.cursor()

sql1 = "select  detailcat, sum(duration) from jmfdata where submaincat = 'Down' and detailCat <> '\N' group by detailcat order by sum(duration) desc"
cursor.execute(sql1)
fracs = cursor.fetchall()

for lines in fracs:
    values.append(lines[1])
    strlegend.append(lines[0])

colors = ('red','pink','orange', 'yellow', 'yellowgreen', 'green','teal','aliceblue','blue','purple')

fig = pl.figure(2, figsize=(11,11))
ax = pl.subplot(111)
width=0.8
pl.title('Down Code Reasons')
ax.bar(range(len(strlegend)), values, width=width,color = colors)
ax.set_xticks(np.arange(len(strlegend)) + width/2)
ax.set_xticklabels(strlegend, rotation=75)
handles, labels = ax.get_legend_handles_labels()
lgd = ax.legend(handles, labels, loc='upper center', bbox_to_anchor=(0.5,-0.1))
fig.savefig('samplefigure03.pdf', bbox_extra_artists=(lgd,), bbox_inches='tight')