Someplace to start:
----
     from matplotlib import cm
     shade = cm.bone_r
     cmstep = shade.N/len(vg_bulk) #TODO: even *more* elegant to space  
colors by time elapsed
     for ii in range(len(vg_bulk)):
         hue = shade(ii*cmstep)
         #convert to moles
         for iii in (0,1,2):
             vg_bulk[ii][1][iii] = vg_bulk[ii][1][iii]*(10**6*22.4)**-1
         ba.plot(vg_bulk[ii][1], vg_sites,
                 color = hue, linestyle=':', marker='o',label='%d  
days'%vg_bulk[ii][0])
----

and here's what I do for linestyle themes, when I don't know how many  
lines I'm going to plot but want adjacent ones to be different (and a  
set of less than seven looks nice):
----
from itertools import cycle
self.linestyleskwargs = cycle(map(lambda tu:  
dict(zip(('color','dashes'),tu)),   (('0.5',(4,1,1,1)),('0.4',(2,1)), 
('0.3',(5,1,2,1)),('0.2',(4,1)),('0.1',(6,1)), ('0.0',(10,1)))))

for g in self.gases.values():
     style = self.linestyleskwargs.next()
     p.plot(g.conc,n.linspace(0,self.depth,self.depth/ 
self.delx),label=g.label, **style)
----

I'm sure either of these examples can be made tidier, or they could be  
combined, or one could set up something to replot all the lines in an  
existing plot, with nicely spaced colors, once you know how many there  
are.

&C

On Jan 16, 2009, at 3:37 PM, Yang Zhang wrote:

> I'm no good at choosing colors.  Does matplotlib have a way to
> automatically assign colors (based on a theme), or provide a way to
> choose a color from a theme?  (Excel 2007 opened my eyes to this.)
> Currently, when I do:
>
>   bar(..., color = 'r', ...)
>   bar(..., color = 'y', ...)
>   bar(..., color = 'b', ...)
>
> I usually just choose one of the primary colors.  It would be nice  
> if I
> could instead write the following (or better if the colors could be
> assigned automagically), so I needn't worry about choosing colors:
>
>   bar(..., color = themecolor(0), ...)
>   bar(..., color = themecolor(1), ...)
>   bar(..., color = themecolor(2), ...)
>
> I see these things called colormaps on the home page documentation,  
> but
> I can't figure out how to use these (calling autumn() before plotting
> made no change to my plot) or whether they're even what I'm looking  
> for.
>  Or perhaps there's some Python package out there completely unrelated
> to matplotlib that I could use?  Thanks in advance for any hints.
> -- 
> Yang Zhang
> http://www.mit.edu/~y_z/
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Chloe Lewis
Graduate student, Amundson Lab
Division of Ecosystem Sciences, ESPM
University of California, Berkeley
137 Mulford Hall - #3114
Berkeley, CA  94720-3114
chle...@nature.berkeley.edu


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to