I am trying to add a color chart on a graph, but I do not understand how this works. The problem is that I create my own color code:
x = np.arange(11) ys = [i+x+(i*x)**2 for i in range(11)] colors = cm.rainbow(np.linspace(0, 1, len(ys)))
and colors[i] will give me a new color. Then I use (home-made) functions to select the appropriate data and build it accordingly. It will look something like this:
function(x,y,concentration,temperature,1,37,colors[0]) function(x,y,concentration,temperature,2,37,colors[1])
Now I want to add colors to the color bar, with shortcuts that I can change. How to do it?
I saw several examples where you build all the data as one array with automatic color bars, but here I draw the data one by one (using functions to select the appropriate data).
EDIT:
the function (x, y, concentration, temperature, 1.37, colors [0]) looks like this (simplified):
def function(x,y,c,T,condition1,condition2,colors): import matplotlib.pyplot as plt i=0 for element in c: if element == condition1: if T[i]==condition2: plt.plot(x,y,color=colors,linewidth=2) i=i+1 return
python matplotlib colorbar
Kay Jansen Oct 24 '14 at 10:10 2014-10-24 10:10
source share