i'm trying make simple 2d plot 3 column data sets e.g. y=f(x) , z=f(x). want plot xy , display z using color. example, rectangular regions between [x1,x2, min(y), max(y)] ... filled background color depending on value of z. tried use fill_between not associate colormap it. i'm new matplotlib , python. appreciate comments/suggestions.
edit: don't have accurate plot i'll try explain query of following figure sample plot
say between x=0.5 x=1, z=1 x=1.0, x=1.5, z=2 ....
so cover x=0.5 x=1 (min(y) max(y)] color corresponds z=1, , between x=1, x=1.5, z=2 , on.. want show variation using colormap , display colorbar @ right side.
it sound me should use contourf
http://matplotlib.org/examples/pylab_examples/contourf_demo.html
this take x
dependant variable, produce y = y(x)
, z = z(x)
. seems z
not dependant on y
contourf can still handle this.
as simple example:
import pylab plt x = plt.linspace(0,2,100) y = plt.linspace(0,10,100) z = [[plt.sinc(i) in x] j in y] cs = plt.contourf(x, y, z, 20, # \[-1, -0.1, 0, 0.1\], cmap=plt.cm.rainbow) plt.colorbar(cs) plt.plot(x,2+plt.sin(y), "--k")
the many variations captures elements looking for
Comments
Post a Comment