From: John H. <jdh...@ac...> - 2004-08-30 13:08:18
|
>>>>> "Jon" == Jon Peirce <Jon...@no...> writes: Jon> On a different topic, imshow() only seems to display a single Jon> image at a time. e.g. in the following example, when image2 Jon> is drawn image1 is deleted. Jon> #------------------------------------------------- import Jon> matplotlib.matlab as mat myImage = mat.imread('image1.png') Jon> myImage2 = mat.imread('image2.png') mat.imshow(myImage, Jon> extent=[0,1,0,1]) mat.imshow(myImage2, extent=[1,2,1,2]) Jon> mat.axis([0, 2, 0, 2]) mat.show() Jon> #------------------------------------------------- Is that a Jon> known issue? Is there a workaround? Jon> all the best, Jon Ahh, interesting case. I put the following line in the Axes.imshow code to protect users from senselessly piling up lots of images if alpha==1: self._images = [] That is, I cleared the image stack if alpha was 1, reasoning you can't see behind a fully opaque image; I was afraid someone might plot lots of images to the same axes with alpha=1 , and never know they were piling up images and hurting performance. I had neglected to consider that you might be using multiple images with different extents. If you comment out that line in matplotlib/axes.py, your example will work. Note that I find it a bit more natural to define separate axes to hold the separate images. Of course, my approach won't work if you want to plot other data, eg lines, that cover multiple images on the same axes, but for simple montages, I think it's cleaner. import matplotlib.matlab as mat myImage = mat.imread('test1.png') myImage2 = mat.imread('test2.png') ax1 = mat.axes([0.5, 0.5, 0.5, 0.5]) ax1.imshow(myImage) mat.axis('off') ax2 = mat.axes([0, 0.0, 0.5, 0.5]) ax2.imshow(myImage2) mat.axis('off') mat.show() JDH |