I want to display images using different color maps in different figures.
Following code displays the image with two different windows but the same color map
import scipy.misc
from pylab import *
a = scipy.misc.imread('lena.jpg')
figure(1)
image = mean(a,axis=2)
imshow(image)
#if I call show() here then only one window is displayed
gray() #change the default colormap to gray
figure(2)
imshow(image)
show()
I am wondering if anyone can please help me.
Thanks a lot.
Create random data using numpy. Add a subplot to the current figure, nrows=1, ncols=4 and at index=1. Display data as an image, i.e., on a 2D regular raster, using imshow() method with cmap="Blues_r".
To do subplots, use the subplot
command (!)
To change the colormap, you can use the cmap
argument of the imshow
function. See the documentation.
figure() # You don't need to specify 1
subplot(121) # 121 is a shortcut for 1 line, 2 columns, item number 1
image = mean(a,axis=2)
imshow(image, cmap='gray')
subplot(122) # 1 line, 2 columns, item number 2
imshow(image, cmap='jet')
show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With