From: Brian B. <bb...@br...> - 2007-02-23 02:57:34
|
Hello, I poked around a bit, and couldn't find the answer to this. Is there a way to specify the default order of line colors and styles, for plot commands given in sequence, like: plot(x1,y1) plot(x2,y2) plot(x3,y3) thanks, Brian Blais -- ----------------- bb...@br... http://web.bryant.edu/~bblais |
From: <jk...@ik...> - 2007-02-23 09:02:12
|
Brian Blais <bb...@br...> writes: > Is there a way to specify the default order of line colors and > styles, for plot commands given in sequence I don't think there is built-in support for this. See e.g. http://thread.gmane.org/gmane.comp.python.matplotlib.general/5708 for some previous discussion and suggestions. -- Jouni K. Seppänen http://www.iki.fi/jks |
From: Fernando P. <fpe...@gm...> - 2007-02-23 09:24:54
|
On 2/23/07, Jouni K. Sepp=E4nen <jk...@ik...> wrote: > Brian Blais <bb...@br...> writes: > > > Is there a way to specify the default order of line colors and > > styles, for plot commands given in sequence > > I don't think there is built-in support for this. See e.g. > http://thread.gmane.org/gmane.comp.python.matplotlib.general/5708 > for some previous discussion and suggestions. It's probably worth mentioning that the cyclers John mentions are trivial to write using itertools: colorcycler =3D itertools.cycle(['blue','green','red','magenta','cyan']) linecycler =3D itertools.cycle([ '-','--', '-.' , ':' ]) n =3D itertools.count() y =3D array([1,2,3]) Then, try: for i in range(10): plot(y+n.next(),color=3Dc.next(),linestyle=3Dlinecycler.next()) plot(y+n.next(),color=3Dc.next(),linestyle=3Dlinecycler.next()) plot(y+n.next(),color=3Dc.next(),linestyle=3Dlinecycler.next()) plot(y+n.next(),color=3Dc.next(),linestyle=3Dlinecycler.next()) plot(y+n.next(),color=3Dc.next(),linestyle=3Dlinecycler.next()) plot(y+n.next(),color=3Dc.next(),linestyle=3Dlinecycler.next()) plot(y+n.next(),color=3Dc.next(),linestyle=3Dlinecycler.next()) plot(y+n.next(),color=3Dc.next(),linestyle=3Dlinecycler.next()) |
From: Fernando P. <fpe...@gm...> - 2007-02-23 09:29:52
|
On 2/23/07, Fernando Perez <fpe...@gm...> wrote: > On 2/23/07, Jouni K. Sepp=E4nen <jk...@ik...> wrote: > > Brian Blais <bb...@br...> writes: > > > > > Is there a way to specify the default order of line colors and > > > styles, for plot commands given in sequence > > > > I don't think there is built-in support for this. See e.g. > > http://thread.gmane.org/gmane.comp.python.matplotlib.general/5708 > > for some previous discussion and suggestions. > > It's probably worth mentioning that the cyclers John mentions are > trivial to write using itertools: Sorry, tab put me in the 'send' button in gmail too early... I meant: import itertools colorcycler =3D itertools.cycle(['blue','green','red','magenta','cyan']).ne= xt linecycler =3D itertools.cycle([ '-','--', '-.' , ':' ]).next n =3D itertools.count().next y =3D array([1,2,3]) for i in range(10): plot(y+n(),color=3Dcolorcycler(),linestyle=3Dlinecycler()) Cheers, f |
From: <jk...@ik...> - 2007-02-23 11:10:18
|
The question of setting the color and line style sequences comes up every now and then, and although there are neat solutions like Fernando demonstrated, perhaps we should add support for them to matplotlib. The Matlab interface seems to be like this: >> figure >> set(gca, 'LineStyleOrder', '-o|-x|-^') % sequence of three line styles >> set(gca, 'ColorOrder', [1 0 0; 0 0 1]) % sequence of two colors (red and blue) >> set(gca, 'NextPlot', 'replacechildren') % don't reset the properties I just set >> plot(random(6)) This plots six lines with different combinations of style and color; the seventh line would look the same as the first. Probably you can avoid the NextPlot thing by setting DefaultLineStyleOrder on the root handle, but never mind. So, to make the interface familiar to Matlab users, I suggest to add properties line.linestyleorder and line.colororder that can take any sequences of linestyles and colors, or an n-by-3 array of rgb color values for the latter. I think the |-separated linestyles spec is a hack (necessary in Matlab because it cannot have vectors of strings because of the auto-flattening matrices) that we shouldn't emulate. How does that sound? -- Jouni K. Seppänen http://www.iki.fi/jks |
From: Eric F. <ef...@ha...> - 2007-02-23 18:40:27
|
Jouni K. Seppänen wrote: > The question of setting the color and line style sequences comes up > every now and then, and although there are neat solutions like > Fernando demonstrated, perhaps we should add support for them to > matplotlib. The Matlab interface seems to be like this: > >>> figure >>> set(gca, 'LineStyleOrder', '-o|-x|-^') % sequence of three line styles >>> set(gca, 'ColorOrder', [1 0 0; 0 0 1]) % sequence of two colors (red and blue) >>> set(gca, 'NextPlot', 'replacechildren') % don't reset the properties I just set >>> plot(random(6)) > > This plots six lines with different combinations of style and color; > the seventh line would look the same as the first. Probably you can > avoid the NextPlot thing by setting DefaultLineStyleOrder on the root > handle, but never mind. > > So, to make the interface familiar to Matlab users, I suggest to add > properties line.linestyleorder and line.colororder that can take any > sequences of linestyles and colors, or an n-by-3 array of rgb color > values for the latter. I think the |-separated linestyles spec is a > hack (necessary in Matlab because it cannot have vectors of strings > because of the auto-flattening matrices) that we shouldn't emulate. > How does that sound? > Are you talking about Axes properties (instance attributes) or rcParam entries or both? In any case, I agree that built-in support would easy to provide and would help enough people to be worthwhile. Eric |
From: <jk...@ik...> - 2007-02-23 20:48:26
|
Eric Firing <ef...@ha...> writes: > Jouni K. Seppänen wrote: >> So, to make the interface familiar to Matlab users, I suggest to add >> properties line.linestyleorder and line.colororder > > Are you talking about Axes properties (instance attributes) or rcParam > entries or both? In any case, I agree that built-in support would easy > to provide and would help enough people to be worthwhile. I was thinking about rcParam entries, but now that you mention it, Axes properties would make more sense. -- Jouni K. Seppänen http://www.iki.fi/jks |