python - Plot with intermediate colors -


i've seen many questions regarding coloring plots, palettes, color maps, etc. want have intermediate colors between default w, m, g, k, b, r.

for instance want plot below gray instead of black.

import numpy np import matplotlib.pylab plt  = np.linspace(1., 4., 6) b = np.array([3,4.,5.3,7.,8,0])  plt.figure() plt.plot(a,b,'ko-',) plt.show() 

you can define colours in many ways matplotlib. docs plt.plot:

in addition [to abbreviations listed above], can specify colors in many weird , wonderful ways, including full names ('green'), hex strings ('#008000'), rgb or rgba tuples ((0,1,0,1)) or grayscale intensities string ('0.8'). of these, string specifications can used in place of fmt group, tuple forms can used kwargs.

so, examples grey in plot:

plt.plot(a,b,'o-',color='grey')  plt.plot(a,b,'o-',color='#808080')  plt.plot(a,b,'o-',color=(0.5,0.5,0.5)  plt.plot(a,b,'o-',color='0.5') 

Comments

Popular posts from this blog

r - how do you merge two data frames the best way? -

How to debug "expected android.widget.TextView but found java.lang.string" in Android? -

php - mySQL problems with this code? -