输入一组要在python的matplotlib中绘制的点时的点颜色规范

时间:2018-07-06 21:12:21

标签: python matplotlib plot colors

注释行没有给出错误,但这不是我想要的。颜色需要针对不同的点进行更改。

def pplot(pdict,pembs,name='np'):
    fig=plt.figure(figsize=(24,24))
    ax=plt.gca()
    ax.cla()
    ax.set_xlim((-1.1,1.1))
    ax.set_ylim((-1.1,1.1))
    ax.add_artist(plt.Circle((0,0),1.,color='black',fill=False))
    c0=[itm[0] for itm in pembs]
    c1=[itm[1] for itm in pembs]
    ax.plot(c0,c1,'o',color=[idcolor.get(i,(0,0,0)) for i in getseg(pdict)],markersize=5)
    #ax.plot(c0,c1,'o',color=(0.0,0.0,0.0),markersize=5)
    txt_height = 0.04/10*(plt.ylim()[1] - plt.ylim()[0])
    txt_width = 0.02/10*(plt.xlim()[1] - plt.xlim()[0])    
    text_positions = get_text_positions(c0, c1, txt_width, txt_height)
    text_plotter(getnps(pdict), c0,c1, text_positions, ax, txt_width, txt_height)

c0c1是向量。我需要一次绘制一个点吗?真的没有办法一次性设置颜色吗?我得到的错误是。

ValueError: to_rgba: Invalid rgba arg "[(0.6484375, 0.76953125, 0.421875), (0.64453125, 0.14453125, 0.69140625), (0.6484375, 0.76953125, 0.421875), (0.98828125, 0.14453125, 0.97265625), (0.29296875, 0.89453125, 0.94921875), (0.97265625, 0.64453125, 0.05078125), (0.32421875, 0.89453125, 0.79296875), (0.6484375, 0.76953125, 0.421875), (0.6484375, 0.76953125, 0.421875), (0.97265625, 0.64453125, 0.05078125), (0.6171875, 0.76953125, 0.578125), (0.9609375, 0.76953125, 0.859375), (0.64453125, 0.14453125, 0.69140625), (0.98828125, 0.14453125, 0.97265625), (0.96484375, 0.39453125, 0.58984375), (0.29296875, 0.89453125, 0.94921875), (0.98828125, 0.14453125, 0.97265625), (0.984375, 0.51953125, 0.2421875), (0.97265625, 0.64453125, 0.05078125), (0.30078125, 0.14453125, 0.41015625), (0.98828125, 0.14453125, 0.97265625), (0.6484375, 0.76953125, 0.421875), (0.6484375, 0.76953125, 0.421875), (0.3203125, 0.26953125, 0.0625), (0.97265625, 0.64453125, 0.05078125), (0.3203125, 0.26953125, 0.0625), (0.6484375, 0.76953125, 0.421875), (0.296875, 0.51953125, 0.6796875), (0.3203125, 0.26953125, 0.0625), (0.98828125, 0.14453125, 0.97265625), (0.9609375, 0.76953125, 0.859375), (0.984375, 0.51953125, 0.2421875), (0.65625, 0.01953125, 0.8828125), (0.3046875, 0.76953125, 0.140625), (0.30078125, 0.14453125, 0.41015625), (0.9765625, 0.26953125, 0.78125), (0.98046875, 0.89453125, 0.51171875), (0.9609375, 0.76953125, 0.859375), (0.64453125, 0.14453125, 0.69140625), (0.98046875, 0.89453125, 0.51171875), (0.3203125, 0.26953125, 0.0625), (0.6484375, 0.76953125, 0.421875), (0.97265625, 0.64453125, 0.05078125), (0.98828125, 0.14453125, 0.97265625), (0.98046875, 0.89453125, 0.51171875), (0.98046875, 0.89453125, 0.51171875), (0.98828125, 0.14453125, 0.97265625), (0.984375, 0.51953125, 0.2421875), (0.98828125, 0.14453125, 0.97265625), (0.3203125, 0.26953125, 0.0625), (0.96484375, 0.39453125, 0.58984375), (0.65625, 0.01953125, 0.8828125), (0.3203125, 0.26953125, 0.0625), (0.6484375, 0.76953125, 0.421875), (0.65234375, 0.39453125, 0.15234375), (0.98046875, 0.89453125, 0.51171875), (0.9765625, 0.26953125, 0.78125), (0.6171875, 0.76953125, 0.578125), (0.98828125, 0.14453125, 0.97265625), (0.3203125, 0.26953125, 0.0625), (0.98828125, 0.14453125, 0.97265625), (0.984375, 0.51953125, 0.2421875), (0.3203125, 0.26953125, 0.0625), (0.63671875, 0.89453125, 0.23046875), (0.6484375, 0.76953125, 0.421875), (0.30078125, 0.14453125, 0.41015625), (0.6484375, 0.76953125, 0.421875), (0.3046875, 0.76953125, 0.140625), (0.296875, 0.51953125, 0.6796875), (0.30078125, 0.14453125, 0.41015625), (0.3203125, 0.26953125, 0.0625), (0.6484375, 0.76953125, 0.421875), (0.65234375, 0.39453125, 0.15234375), (0.9609375, 0.76953125, 0.859375), (0.3046875, 0.76953125, 0.140625), (0.65234375, 0.39453125, 0.15234375), (0.3046875, 0.76953125, 0.140625), (0.98828125, 0.14453125, 0.97265625), (0.65625, 0.01953125, 0.8828125), (0.9765625, 0.26953125, 0.78125), (0.65234375, 0.39453125, 0.15234375), (0.97265625, 0.64453125, 0.05078125), (0.30078125, 0.14453125, 0.41015625), (0.3046875, 0.76953125, 0.140625), (0.6484375, 0.76953125, 0.421875), (0.6328125, 0.26953125, 0.5), (0.29296875, 0.89453125, 0.94921875), (0.65625, 0.01953125, 0.8828125), (0.98046875, 0.89453125, 0.51171875), (0.97265625, 0.64453125, 0.05078125), (0.98046875, 0.89453125, 0.51171875), (0.6484375, 0.76953125, 0.421875), (0.29296875, 0.89453125, 0.94921875), (0.97265625, 0.64453125, 0.05078125), (0.9765625, 0.26953125, 0.78125), (0.9765625, 0.26953125, 0.78125), (0.97265625, 0.64453125, 0.05078125), (0.984375, 0.51953125, 0.2421875), (0.98046875, 0.89453125, 0.51171875), (0.65625, 0.01953125, 0.8828125), (0.97265625, 0.64453125, 0.05078125), (0.97265625, 0.64453125, 0.05078125), (0.64453125, 0.14453125, 0.69140625), (0.9765625, 0.26953125, 0.78125), (0.9765625, 0.26953125, 0.78125), (0.9765625, 0.26953125, 0.78125), (0.9765625, 0.26953125, 0.78125), (0.65234375, 0.39453125, 0.15234375), (0.98828125, 0.14453125, 0.97265625), (0.65625, 0.01953125, 0.8828125), (0.98828125, 0.14453125, 0.97265625), (0.29296875, 0.89453125, 0.94921875), (0.65625, 0.01953125, 0.8828125), (0.65234375, 0.39453125, 0.15234375), (0.29296875, 0.89453125, 0.94921875), (0.65625, 0.01953125, 0.8828125), (0.98828125, 0.14453125, 0.97265625), (0.98046875, 0.89453125, 0.51171875), (0.98828125, 0.14453125, 0.97265625), (0.3203125, 0.26953125, 0.0625), (0.9765625, 0.26953125, 0.78125), (0.9765625, 0.26953125, 0.78125), (0.984375, 0.51953125, 0.2421875), (0.9765625, 0.26953125, 0.78125), (0.63671875, 0.89453125, 0.23046875), (0.64453125, 0.14453125, 0.69140625), (0.96484375, 0.39453125, 0.58984375), (0.97265625, 0.64453125, 0.05078125), (0.98828125, 0.14453125, 0.97265625), (0.29296875, 0.89453125, 0.94921875), (0.984375, 0.51953125, 0.2421875), (0.296875, 0.51953125, 0.6796875), (0.9765625, 0.26953125, 0.78125), (0.9609375, 0.76953125, 0.859375), (0.97265625, 0.64453125, 0.05078125), (0.63671875, 0.89453125, 0.23046875), (0.96484375, 0.39453125, 0.58984375), (0.98046875, 0.89453125, 0.51171875), (0.65625, 0.01953125, 0.8828125), (0.64453125, 0.14453125, 0.69140625), (0.98046875, 0.89453125, 0.51171875), (0.63671875, 0.89453125, 0.23046875), (0.98828125, 0.14453125, 0.97265625), (0.63671875, 0.89453125, 0.23046875), (0.97265625, 0.64453125, 0.05078125), (0.65625, 0.01953125, 0.8828125), (0.3203125, 0.26953125, 0.0625), (0.3203125, 0.26953125, 0.0625), (0.98046875, 0.89453125, 0.51171875), (0.65234375, 0.39453125, 0.15234375), (0.64453125, 0.14453125, 0.69140625), (0.98046875, 0.89453125, 0.51171875), (0.3203125, 0.26953125, 0.0625), (0.98828125, 0.14453125, 0.97265625), (0.6171875, 0.76953125, 0.578125), (0.3046875, 0.76953125, 0.140625), (0.98046875, 0.89453125, 0.51171875), (0.65234375, 0.39453125, 0.15234375), (0.97265625, 0.64453125, 0.05078125), (0.98828125, 0.14453125, 0.97265625), (0.6484375, 0.76953125, 0.421875), (0.6484375, 0.76953125, 0.421875), (0.98046875, 0.89453125, 0.51171875), (0.97265625, 0.64453125, 0.05078125), (0.9765625, 0.26953125, 0.78125), (0.6484375, 0.76953125, 0.421875), (0.98046875, 0.89453125, 0.51171875), (0.98828125, 0.14453125, 0.97265625), (0.97265625, 0.64453125, 0.05078125), (0.6171875, 0.76953125, 0.578125), (0.64453125, 0.14453125, 0.69140625), (0.97265625, 0.64453125, 0.05078125), (0.65625, 0.01953125, 0.8828125), (0.65234375, 0.39453125, 0.15234375), (0.9765625, 0.26953125, 0.78125), (0.98046875, 0.89453125, 0.51171875), (0.64453125, 0.14453125, 0.69140625), (0.6328125, 0.26953125, 0.5), (0.6171875, 0.76953125, 0.578125), (0.3203125, 0.26953125, 0.0625), (0.98046875, 0.89453125, 0.51171875), (0.64453125, 0.14453125, 0.69140625), (0.29296875, 0.89453125, 0.94921875), (0.6484375, 0.76953125, 0.421875), (0.98828125, 0.14453125, 0.97265625), (0.98046875, 0.89453125, 0.51171875), (0.98828125, 0.14453125, 0.97265625), (0.65625, 0.01953125, 0.8828125), (0.29296875, 0.89453125, 0.94921875), (0.64453125, 0.14453125, 0.69140625), (0.64453125, 0.14453125, 0.69140625), (0.6328125, 0.26953125, 0.5), (0.97265625, 0.64453125, 0.05078125), (0.98828125, 0.14453125, 0.97265625), (0.6484375, 0.76953125, 0.421875), (0.29296875, 0.89453125, 0.94921875), (0.3203125, 0.26953125, 0.0625), (0.3203125, 0.26953125, 0.0625), (0.3203125, 0.26953125, 0.0625), (0.9765625, 0.26953125, 0.78125), (0.98046875, 0.89453125, 0.51171875), (0.96484375, 0.39453125, 0.58984375), (0.65625, 0.01953125, 0.8828125), (0.98828125, 0.14453125, 0.97265625), (0.29296875, 0.89453125, 0.94921875), (0.6171875, 0.76953125, 0.578125), (0.97265625, 0.64453125, 0.05078125), (0.6328125, 0.26953125, 0.5), (0.98046875, 0.89453125, 0.51171875), (0.30078125, 0.14453125, 0.41015625), (0.97265625, 0.64453125, 0.05078125), (0.65625, 0.01953125, 0.8828125), (0.6171875, 0.76953125, 0.578125), (0.296875, 0.51953125, 0.6796875), (0.9765625, 0.26953125, 0.78125), (0.98046875, 0.89453125, 0.51171875), (0.9765625, 0.26953125, 0.78125), (0.6171875, 0.76953125, 0.578125), (0.64453125, 0.14453125, 0.69140625), (0.65625, 0.01953125, 0.8828125), (0.30078125, 0.14453125, 0.41015625), (0.3203125, 0.26953125, 0.0625), (0.98828125, 0.14453125, 0.97265625), (0.96484375, 0.39453125, 0.58984375), (0.97265625, 0.64453125, 0.05078125), (0.9765625, 0.26953125, 0.78125), (0.65625, 0.01953125, 0.8828125), (0.98046875, 0.89453125, 0.51171875), (0.29296875, 0.89453125, 0.94921875), (0.6484375, 0.76953125, 0.421875), (0.65234375, 0.39453125, 0.15234375), (0.64453125, 0.14453125, 0.69140625), (0.97265625, 0.64453125, 0.05078125), (0.9609375, 0.76953125, 0.859375), (0.32421875, 0.89453125, 0.79296875), (0.3203125, 0.26953125, 0.0625), (0.984375, 0.51953125, 0.2421875), (0.98828125, 0.14453125, 0.97265625), (0.6328125, 0.26953125, 0.5), (0.30078125, 0.14453125, 0.41015625), (0.6484375, 0.76953125, 0.421875), (0.98828125, 0.14453125, 0.97265625), (0.6484375, 0.76953125, 0.421875), (0.9765625, 0.26953125, 0.78125), (0.65625, 0.01953125, 0.8828125), (0.3203125, 0.26953125, 0.0625), (0.64453125, 0.14453125, 0.69140625), (0.3046875, 0.76953125, 0.140625), (0.63671875, 0.89453125, 0.23046875), (0.65625, 0.01953125, 0.8828125), (0.3203125, 0.26953125, 0.0625), (0.64453125, 0.14453125, 0.69140625), (0.3203125, 0.26953125, 0.0625), (0.98046875, 0.89453125, 0.51171875), (0.9765625, 0.26953125, 0.78125), (0.97265625, 0.64453125, 0.05078125), (0.97265625, 0.64453125, 0.05078125), (0.9765625, 0.26953125, 0.78125), (0.984375, 0.51953125, 0.2421875), (0.29296875, 0.89453125, 0.94921875), (0.9609375, 0.76953125, 0.859375), (0.64453125, 0.14453125, 0.69140625), (0.65625, 0.01953125, 0.8828125), (0.65625, 0.01953125, 0.8828125), (0.97265625, 0.64453125, 0.05078125), (0.296875, 0.51953125, 0.6796875), (0.98046875, 0.89453125, 0.51171875), (0.98046875, 0.89453125, 0.51171875), (0.64453125, 0.14453125, 0.69140625), (0.98046875, 0.89453125, 0.51171875), (0.97265625, 0.64453125, 0.05078125), (0.98828125, 0.14453125, 0.97265625), (0.98828125, 0.14453125, 0.97265625), (0.98828125, 0.14453125, 0.97265625), (0.3203125, 0.26953125, 0.0625), (0.98046875, 0.89453125, 0.51171875), (0.6171875, 0.76953125, 0.578125), (0.98828125, 0.14453125, 0.97265625), (0.64453125, 0.14453125, 0.69140625), (0.3203125, 0.26953125, 0.0625), (0.98828125, 0.14453125, 0.97265625), (0.6484375, 0.76953125, 0.421875), (0.65234375, 0.39453125, 0.15234375), (0.984375, 0.51953125, 0.2421875), (0.32421875, 0.89453125, 0.79296875), (0.63671875, 0.89453125, 0.23046875), (0.64453125, 0.14453125, 0.69140625), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)]"
length of rgba sequence should be either 3 or 4

谢谢。

0 个答案:

没有答案