set_colors() not working for line collection

I should mention my import lines:

import numpy as np
from numpy import sum, zeros, less, where
import scipy as sp

import matplotlib.pyplot as plt
from matplotlib import collections
from matplotlib.colors import colorConverter

···

On Thu, 01 May 2008 22:00:33 +0000, Zoho Vignochi wrote:

Hello:

I have a script in which I have been using plot to plot numerous lines
on the same graph. I recently wanted to see how Line Collections work so
I tried porting it over. Everything successful except I can't seem to
get each line to be a different color. Here is the relevant section:

# Make a list of colors cycling through the rgbcmyk series.
  colors = [colorConverter.to_rgba(c) for c in
('r','g','b','c','y','m','k')]
  
  fig = plt.figure()
  ax = fig.add_subplot(1,1,1)
  lines = collections.LineCollection([zip(L_range, item) for item
in a_steady])
  lines.set_array(L_range)
  lines.set_color(colors)
  ax.add_collection(lines, autolim=True)
  
However every line is blue. Any ideas?

I converted your example to a standalone one (attached), and it does work for me. It's hard to say what may be going wrong for you without knowing what a_steady and L_range are and what the limits of the axes are getting set to etc. Can you provide a fully self-contained script that exhibits this behavior? Also, what version of matplotlib and platform are you using?

Cheers,
Mike

Zoho Vignochi wrote:

line_collection.py (551 Bytes)

···

On Thu, 01 May 2008 22:00:33 +0000, Zoho Vignochi wrote:

Hello:

I have a script in which I have been using plot to plot numerous lines
on the same graph. I recently wanted to see how Line Collections work so
I tried porting it over. Everything successful except I can't seem to
get each line to be a different color. Here is the relevant section:

# Make a list of colors cycling through the rgbcmyk series.
  colors = [colorConverter.to_rgba(c) for c in
('r','g','b','c','y','m','k')]
  
  fig = plt.figure()
  ax = fig.add_subplot(1,1,1)
  lines = collections.LineCollection([zip(L_range, item) for item
in a_steady])
  lines.set_array(L_range)
  lines.set_color(colors)
  ax.add_collection(lines, autolim=True)
  
However every line is blue. Any ideas?

I should mention my import lines:

import numpy as np
from numpy import sum, zeros, less, where
import scipy as sp

import matplotlib.pyplot as plt
from matplotlib import collections
from matplotlib.colors import colorConverter

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Hello:

I am running Debian sid on Powerpc and I have the Debian sid
python-matplotlib version 0.91.2-2. Your stand alone script also works
for me. Strange.

I have included the script I am using set to plot 5 lines. The script is
designed to solve the Daisyworld model proposed by James Lovelock in the
early 80's. Thank you for your help!

Zoho

daisy_power.py (4.1 KB)

···

On Fri, 2008-05-02 at 08:33 -0400, Michael Droettboom wrote:

I converted your example to a standalone one (attached), and it does
work for me. It's hard to say what may be going wrong for you without
knowing what a_steady and L_range are and what the limits of the axes
are getting set to etc. Can you provide a fully self-contained script
that exhibits this behavior? Also, what version of matplotlib and
platform are you using?

Cheers,
Mike