hmmm... in response to John's earlier request I cobbled a simple example
but that seems to work; either there's a strange error in the more
complex version or my misunderstanding of color maps is messing with me.
Anyway, for the record, here's an example of what I want to do (that
actually seems to work)

#!/usr/bin/env python
# Example to try and use same color maps for scatter and imshow
import numpy as np
from pylab import *
# size of array dimensions
size = 10
# cluster centers
acenter1 = 3.0
asigma1 = 1.0
bcenter1 = 6.0
bsigma1 = 0.5
acenter2 = 8.0
asigma2 = 2.0
bcenter2 = 3.0
bsigma2 = 1.0
acenter3 = 13.0
asigma3 = 2.0
bcenter3 = 10.0
bsigma3 = 1.0
# populate arrays with random values distrubted about 2 locations
# (i.e. 2 clusters)
a = np.zeros([size,size],float)
b = np.zeros([size,size],float)
c = np.zeros([size,size],int)
# populate arrays
for i in range(size):
for j in range(size):
switcher = np.random.randint(3)
if switcher == 0: # cluster 1
a[i,j] = np.random.normal(acenter1,asigma1)
b[i,j] = np.random.normal(bcenter1,bsigma1)
c[i,j] = 0
elif switcher == 1 : # cluster 2
a[i,j] = np.random.normal(acenter2,asigma2)
b[i,j] = np.random.normal(bcenter2,bsigma2)
c[i,j] = 1
else:
a[i,j] = np.random.normal(acenter3,asigma3)
b[i,j] = np.random.normal(bcenter3,bsigma3)
c[i,j] = 2
hot()
subplot(1,2,1)
scatter(np.ravel(a),np.ravel(b),c=np.ravel(c))
subplot(1,2,2)
imshow(c)
show()

> Young, Karl wrote:
>
>> 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.
>>
>>
>
> Karl,
>
> It sounds like you need to specify the norm=colors.NoNorm() argument.
> http://matplotlib.sourceforge.net/api/colors_api.html?highlight=nonorm#matplotlib.colors.NoNorm
> Then if your data are integers (typed as integers, not just taking
> integer values), they will be interpreted as indices into the color
> table. You will probably also want to generate that table yourself and
> specify it via the cmap=my_cmap kwarg. If you have only a few values,
> then you may want to generate it as a colors.ListedColormap:
> http://matplotlib.sourceforge.net/api/colors_api.html?highlight=listedcolormap#matplotlib.colors.ListedColormap
> http://matplotlib.sourceforge.net/examples/api/colorbar_only.html?highlight=listedcolormap
>
> It looks like we don't have any good examples sitting around showing the
> use of NoNorm; but try it anyway.
>
> Eric
>
> .
>
>
