我只是想用matplotlib的eventplot绘制一些特定颜色的记号。我在Jupyter笔记本中运行Python 3,并使用%matplotlib inline。
下面是一个示例代码:
import numpy as np
import matplotlib.pyplot as plt
spikes = 100*np.random.random(100)
plt.eventplot(spikes, orientation='horizontal', linelengths=0.9, color=[0.3,0.3,0.5])
它输出以下错误:
ValueError: colors and positions are unequal sized sequences
这个错误可能是因为我没有提供与数据长度相同的颜色列表(但我不希望它们都是相同的颜色!)。当我使用像“深红色”或“兰花”这样的颜色字符串时,也会出现错误。但当我使用一个简单的单字母字符串如“r”时,它就起作用了。
我真的只限于使用极为有限的一个字母的颜色字符串'r'、'b'、'g'、'k'、'm'、'y'等等。。。或者在使用此事件图时制作一个长颜色列表?
根据docs:
相关问题 更多 >
编程相关推荐