 # Help with Colormaps

Hi there,
I’ve been spending hours trying to get the colormaps to work, and I am still having no luck. All the examples I have found seem to use imshow() rather than the figure() and plot(). This is a very simple thing I am trying to do, a 2D x-y plot, with z values represented by a color.
Basically, I have 3 numpy ndarrays:
x - x values
y - y values
z - color values
Obviously, it is trivial to plot the x and y values:
plt.plot(x, y, “bo”)
But how to I use the z array to use the inbuilt colormap features?
I’ve tried things like:
plt.plot(x, y, color=matplotlib.cm.jet(z), marker=‘o’, markersize=6)

But it doesn’t seem to work - how do I get this working?

many thanks
Geoff Sims

I used something similar to the following recently that gave the scatter points a different colour depending on the z-axis values.

chart = pylab.scatter(x, y, c=z, edgecolors=‘none’)

colourbar = pylab.colorbar()

I’m sorry I can’t give you better information about the colormap features though.

Cheers,

Jervis

···

On Thu, Apr 29, 2010 at 9:00 AM, Geoff Sims <geoffrey.sims@…287…> wrote:

Hi there,
I’ve been spending hours trying to get the colormaps to work, and I am still having no luck. All the examples I have found seem to use imshow() rather than the figure() and plot(). This is a very simple thing I am trying to do, a 2D x-y plot, with z values represented by a color.
Basically, I have 3 numpy ndarrays:
x - x values
y - y values
z - color values
Obviously, it is trivial to plot the x and y values:
plt.plot(x, y, “bo”)
But how to I use the z array to use the inbuilt colormap features?
I’ve tried things like:
plt.plot(x, y, color=matplotlib.cm.jet(z), marker=‘o’, markersize=6)

But it doesn’t seem to work - how do I get this working?

many thanks
Geoff Sims

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Thanks Jervis,

I was able to get it to work!

Geoff

···

On 29 April 2010 09:09, Jervis Whitley <jervisau@…287…> wrote:

On Thu, Apr 29, 2010 at 9:00 AM, Geoff Sims <geoffrey.sims@…287…> wrote:

Hi there,
I’ve been spending hours trying to get the colormaps to work, and I am still having no luck. All the examples I have found seem to use imshow() rather than the figure() and plot(). This is a very simple thing I am trying to do, a 2D x-y plot, with z values represented by a color.
Basically, I have 3 numpy ndarrays:
x - x values
y - y values
z - color values
Obviously, it is trivial to plot the x and y values:
plt.plot(x, y, “bo”)
But how to I use the z array to use the inbuilt colormap features?
I’ve tried things like:
plt.plot(x, y, color=matplotlib.cm.jet(z), marker=‘o’, markersize=6)

But it doesn’t seem to work - how do I get this working?

many thanks
Geoff Sims

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I used something similar to the following recently that gave the scatter points a different colour depending on the z-axis values.

chart = pylab.scatter(x, y, c=z, edgecolors=‘none’)

colourbar = pylab.colorbar()

I’m sorry I can’t give you better information about the colormap features though.

Cheers,

Jervis