python - How to make this graph in plolty -
is graph several lines using colorbar. unable using plotly. want make hydrograph, each line represents 1 year.
import matplotlib mpl import matplotlib.pyplot plt min, max = (-40, 30) step = 10 # setting colormap that's simple transtion mymap = mpl.colors.linearsegmentedcolormap.from_list('mycolors',['blue','red']) # using contourf provide colorbar info, clearing figure z = [[0,0],[0,0]] levels = range(min,max+step,step) cs3 = plt.contourf(z, levels, cmap=mymap) plt.clf() # plotting want x=[[1,2],[1,2],[1,2],[1,2]] y=[[1,2],[1,3],[1,4],[1,5]] z=[-40,-20,0,30] x,y,z in zip(x,y,z): # setting rgb color based on z normalized range r = (float(z)-min)/(max-min) g = 0 b = 1-r plt.plot(x,y,color=(r,g,b)) plt.colorbar(cs3) # using colorbar info got contourf plt.show()
Comments
Post a Comment