[Matplotlib-users] strange coloring of a tiled raster image
Hello,
I wish to plot 4 different raster images within a figure, and later
plot registered lines highlighting certain features of them.
Here is the code to read one image and plot it, works as expcted:
img = Image.open(sys.argv[1])
img1 = numpy.asarray(img)
pylab.figure()
pylab.imshow(img1)
pylab.savefig('_imgok.jpg')
Now, make a double-sized image array, and tile the original image into it:
pylab.figure()
YRES = img1.shape[0]
XRES = img1.shape[1]
twoimg = numpy.zeros((2*YRES,2*XRES,3))
#twoimg = numpy.empty((2*YRES,2*XRES,3),numpy.uint32)
twoimg[0:YRES,0:XRES,:] = img1
twoimg[0:YRES,XRES:2*XRES,:] = img1
twoimg[YRES:2*YRES,0:XRES,:] = img1
pylab.imshow(twoimg, origin='upper', interpolation='nearest')
pylab.gray()
pylab.savefig('_imgproblem.jpg')
It comes out strangely colored, vaguely as if the red and green channels were
swapped. However, that's not it (I tried swapping).
This is with maaplib-0.91 (-2?) on a mac 10.4.11, and I think
the backend is GTKAgg
Thanks for any advice
(recent convert from matlab, quite happy...)
__
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com -
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] anim.py questions
I have a couple questions about anim.py: http://matplotlib.sourceforge.net/examples/anim.py I'm running Python 2.5.1 and Matplotlib 0.90.1 under Win 2000. 1. Running anim.py at DOS prompt: it runs correctly until the end: Fatal Python error: PyEval_RestoreThread: NULL tstate This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. How can I get rid of this error? 2. Running under the Python interpreter (using execfile): The Tk window will not display until the script has finished running, so the animation cannot be viewed. How can I run this animation from the interpreter window? Thank you, Alan Isaac - 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 [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] integers -> colors
I have an integer array. The number of different integers is small, so small that I would like to define an integer to color mapping and use this with matshow. E.g., 0 -> black 1 -> red 2 -> blue etc Possible? Thank you, Alan Isaac - 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 [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] integers -> colors
Alan, It sounds like what you want is a listed colormap with direct indexing using a NoNorm() instance as the norm: aa = ones((2,3), dtype=int) aa[0,0] = 0 aa[:,2] = 2 cmap = mpl.colors.ListedColormap(['k', 'r', 'b']) norm = mpl.colors.NoNorm() matshow(aa, cmap=cmap, norm=norm, interpolation='nearest') The array has to be one of the integer dtypes. Also see examples/colorbar_only.py if you want to use a colorbar--but I suspect you won't for your present application. Eric Alan G Isaac wrote: > I have an integer array. > The number of different integers is small, > so small that I would like to define an > integer to color mapping and use this > with matshow. E.g., > 0 -> black > 1 -> red > 2 -> blue > etc > > Possible? > > Thank you, > Alan Isaac > > > > - > 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 > [email protected] > https://lists.sourceforge.net/lists/listinfo/matplotlib-users - 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 [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
