How to pass rgb color values to python's matplotlib eventplot? -
i'm trying plot tick marks specific color using matplotlib's eventplot. i'm running python 3 in jupyter notebook %matplotlib inline.
here's example code:
import numpy np import matplotlib.pyplot plt spikes = 100*np.random.random(100) plt.eventplot(spikes, orientation='horizontal', linelengths=0.9, color=[0.3,0.3,0.5])
it outputs following error:
valueerror: colors , positions unequal sized sequences
the error occurs presumably because not providing list of colors of same length data (but wan't them same color!). gives error when use color string 'crimson' or 'orchid'. works when use simple one-letter string 'r'.
am restricted using extremely limited set of one-letter color strings 'r','b','g','k','m','y', etc... or making long color list when using eventplot?
according docs:
you can pass (r, g, b) or (r, g, b, a) tuple, each of r, g, b , in range [0,1].
import numpy np import matplotlib.pyplot plt spikes = 100*np.random.random(100) plt.eventplot(spikes, orientation='horizontal', linelengths=0.9, color = [(0.3,0.3,0.5)]) plt.show()
Comments
Post a Comment