如果我用一个调用绘制各种不相交的行,如下所示......
>>> import matplotlib.pyplot as plt
>>> x = [random.randint(0,9) for i in range(10)]
>>> y = [random.randint(0,9) for i in range(10)]
>>> data = []
>>> for i in range(0,10,2):
... data.append((x[i], x[i+1]))
... data.append((y[i], y[i+1]))
...
>>> print(data)
[(6, 4), (4, 3), (6, 5), (0, 4), (0, 0), (2, 2), (2, 0), (6, 5), (2, 5), (3, 6)]
>>> plt.plot(*data)
[<matplotlib.lines.Line2D object at 0x0000022A20046E48>, <matplotlib.lines.Line2D object at 0x0000022A2004D048>, <matplotlib.lines.Line2D object at 0x0000022A2004D9B0>, <matplotlib.lines.Line2D object at 0x0000022A20053208>, <matplotlib.lines.Line2D object at 0x0000022A20053A20>]
>>> plt.show()
我无法弄清楚如何让python / matplotlib将其视为单个图,具有相同的颜色,线宽,ect和相同的图例条目......
提前谢谢
答案 0 :(得分:1)
如果你不介意将它们全部合并为一行而不是简单地使用plt.plot(x,y)
。但是我想你想把它们分开来。为此,您可以指定绘图comamnd的样式参数,然后使用Stop matplotlib repeating labels in legend中的代码来防止多个图例条目。
import matplotlib.pyplot as plt
import numpy as np
from collections import OrderedDict
x = [np.random.randint(0,9) for i in range(10)]
y = [np.random.randint(0,9) for i in range(10)]
data = []
for i in range(0,10,2):
data.append((x[i], x[i+1]))
data.append((y[i], y[i+1]))
#Plot all with same style and label.
plt.plot(*data,linestyle='-',color='blue',label='LABEL')
#Single Legend Label
handles, labels = plt.gca().get_legend_handles_labels()
by_label = OrderedDict(zip(labels, handles))
plt.legend(by_label.values(), by_label.keys())
#Show Plot
plt.show()
答案 1 :(得分:0)
这个怎么样?
SELECT top 1 o.* ,trs.TRN_IDN
FROM OFFENSE o
inner join CCH_PUBLIC.dbo.TRS trs on trs.TRS_IDN = o.TRS_IDN
inner join CCH_PUBLIC.dbo.TRN trn on trn.TRN_IDN = trs.TRN_IDN
inner join CCH_PUBLIC.dbo.PERSON p on p.IND_IDN = trn .IND_IDN
where p.PER_IDN = @PER_IDN