Thanks for the tip and sorry I didn't include a complete code snippet; the 
current code involves images (scipy.ndimage) and clustering code and I thought 
that was a little too much too include; I'll try to extract something simpler. 
I guess the main question is how to use a set of integers to index a color 
space consistently for both scatter and imshow but I'll try to come up with a 
simple example. Thanks agan.

________________________________________
From: John Hunter [jdh2...@gmail.com]
Sent: Friday, June 05, 2009 5:43 AM
To: Young, Karl
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] consistent colors between imshow and scatter

On Thu, Jun 4, 2009 at 6:38 PM, Karl Young<karl.yo...@ucsf.edu> wrote:
>
> I have 2 float arrays of the same dimension which I use to generate a
> 3rd array, again of the same dimension, containing integers from a small
> set (I obtain the 3rd array via clustering in the 2 dimensional space of
> points obtained as values from the same location in the initial 2
> arrays). I'd like to do a scatter plot using scatter, with x-axis values
> as values from the first array, y-values as values from the second array
> and color of the points corresponding to the integer in the 3rd array
> (so far so good; I can do that much). Then I'd like to plot an image
> using imshow of the 3rd array with colors corresponding to those in the
> scatter plot. I can generate the image with imshow ok but can't the
> colors to match those in the scatter plot. Here's a snippet (assume
> array1,array2, and array3 are 2D arrays):
>
> hot()
> scatter(array1.ravel(), array2.ravel(), c =
> numpy.array(array3.ravel(),float))
>  imshow(array3)
> show()
>
> The main problem is that I can't figure out how to force the plot colors
> for imshow to correspond to those in scatter. Thanks for any thought or
> suggestions. Cheers,


w/o a complete, self contained code sample that we can run and play
with on our machines, it is harder to help.  Have you tried forcing
the clim to be set to the interval you want?

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.clim

JDH

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to