On Jun 15, 10:32 am, Wanderer <wande...@dialup4less.com> wrote: > On Jun 15, 11:04 am, Ravikanth <vvnrk.vanapa...@gmail.com> wrote: > > > > > > > Hi all, > > > I am a beginner in python. I need to implement a graph with multiple > > colors in it. > > In a way, I have a function which varies with respect to time and > > amplitude. I have time on x-axis and amplitude on y-axis. Lets say the > > amplitude of the graph is divided into 4 ranges, say 1-3,3-5,5-9, > > 10-3. I need to plot the graph in such a way that, when the values of > > amplitude are in a particular range say 1-3, the color of graph should > > be red. > > If the amplitude is in the range from 3-5 the graph need to be in > > color blue etc.., > > > Can somebody guide me on this, how to achive this functionality. > > > Regards, > > Ravikanth > > Check out the examples in matplotlib. > > http://matplotlib.sourceforge.net/examples/pylab_examples/multicolore...- > Hide quoted text - > > - Show quoted text -
I did go through the side wanderer. I wasn't able to figure out the usage of boundaryNorm and lc.set_array(z) , in that link. according to my understanding, cmap = ListedColormap(['r', 'g', 'b']) norm = BoundaryNorm([-1, -0.5, 0.5, 1], cmap.N) In the above lines of code, as per my understanding, Listedcolor map, maps the colors r,g and b to specific indexes into cmap i.e cmap(0) represents red, cmap(1) represents blue cmap(2) represents green. for any index greater than 3 a color of blue is returned.. >>> cmap = ListedColormap(['r', 'g', 'b']) >>> cmap(0) (1.0, 0.0, 0.0, 1.0) >>> cmap(1) (0.0, 0.5, 0.0, 1.0) >>> cmap(2) (0.0, 0.0, 1.0, 1.0) >>> cmap(3) (0.0, 0.0, 1.0, 1.0) In this context, I was not able to understand what does boundaryNorm does. We have 3 colors and we are using 4 values as argument in boundaryNorm. [-1, -0.5, 0.5, 1], the comment reads slope of 'z' is being mapped to the values in boundary norm. How is it handled. Does the function call " lc.set_array(z) " does it ? what is the exact use of linecollection.set_array(z) in this context. Thanks, Ravikanth -- http://mail.python.org/mailman/listinfo/python-list