Hi Tony,

thanks for the pointer.  that code does not run for me, it generates the
following error:

ttributeError                            Traceback (most recent call last)

color_cycle.py in <module>()
     63 if __name__ == '__main__':
     64     n_lines = 10
---> 65     cycle_cmap(length=n_lines)
     66     x = np.linspace(0, 10)
     67     for shift in np.linspace(0, np.pi, n_lines):

color_cycle.py in cycle_cmap(cmap, length)
     59     idx = np.linspace(crange['start'], crange['stop'],
length).astype(np.int)
     60     colors = cm(idx)
---> 61     mpl.axes.set_default_color_cycle(colors.tolist())
     62
     63 if __name__ == '__main__':

/Library/Python/2.5/site-packages/matplotlib/axes.pyc in
set_default_color_cycle(clist)
    113     """
    114     _process_plot_var_args.defaultColors = clist[:]
--> 115     rcParams['lines.color'] = clist[0]
    116
    117 class _process_plot_var_args:

/Library/Python/2.5/site-packages/matplotlib/__init__.pyc in
__setitem__(self, key, val)
    603 instead.'% (key, alt))
    604                 key = alt
--> 605             cval = self.validate[key](val)
    606             dict.__setitem__(self, key, cval)
    607         except KeyError:

/Library/Python/2.5/site-packages/matplotlib/rcsetup.pyc in
validate_color(s)
    160 def validate_color(s):
    161     'return a valid color arg'
--> 162     if s.lower() == 'none':
    163         return 'None'
    164     if is_color_like(s):

AttributeError: 'list' object has no attribute 'lower'
WARNING: Failure executing file: <color_cycle.py>

any idea what might be wrong?


On Tue, Jul 14, 2009 at 10:14 AM, Tony S Yu <ton...@mit.edu> wrote:

> Not too long ago, I posted an example of this to the 
> list<http://www.nabble.com/Where-to-post-examples-%2528specifically%252C-one-that-may-be-useful-for-time-evolution-plots%2529-td23901837.html>.
> The code near the bottom of that thread is a little more general than the
> one at the top and shows, three different ways to cycle through the colors
> of a colormap.
>
> Hope that helps,
> -Tony
>
>
> On Jul 14, 2009, at 9:51 AM, per freem wrote:
>
> Hi all,
>
> i would like to set the colors of the lines i plot (using the plot
> function) to go from red to blue, in evenly spaced interval. that is,
> imagine a color map from red to green, where i plot n-many lines, each
> receiving a color from this color map, starting at the red end and going to
> green.
>
> the docs say how to set the color cycle of lines set by plot, using:
>
> matplotlib.axes.set_default_color_cycle(['r', 'y', 'g', 'b'])
>
> but this only allows me to use named colors, and here i am looking to use
> shades from red to green.
> my question is: first, how can i generate N evenly spaced colors from the
> red spectrum to the green spectrum? and two, how can i make it so plot uses
> these colors for its line plots?
>
> thanks very much.
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
>
> details at:
> http://p.sf.net/sfu/Challenge_______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to