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

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -