imshow

Set two matplotlib imshow plots to have the same color map scale

二次信任 提交于 2019-12-04 10:38:20
问题 I am trying to plot to fields with the same scale. The upper image values are a 10 times higher than the one bellow, but they turn out to be the same color in the imshow. How can I set both to have the same scales in colours? I added the code I am using bellow the image.. def show_field(field1,field2): fig = plt.figure() ax = fig.add_subplot(2, 1, 1) ax.imshow(field1,cmap=plt.cm.YlGn) ax.set_adjustable('box-forced') ax.autoscale(False) ax2 = fig.add_subplot(2, 1, 2) ax2.set_adjustable('box

The difference between uint8 and double images when using imshow

雨燕双飞 提交于 2019-12-04 05:39:37
问题 The following code snippet results a double image. f = imread('C:\Users\Administrator\Desktop\2.tif'); h = double(f); figure; imshow(h); whereas, this other code snippet results a uint8 image. f = imread('C:\Users\Administrator\Desktop\2.tif'); figure; imshow(f); While displaying these two figures, the displayed results of these two images using imshow are different, but what is the reason behind this difference? 回答1: Images of type double are assumed to have values between 0 and 1 and uint8

Matplotlib : display array values with imshow

本小妞迷上赌 提交于 2019-12-03 06:59:10
问题 I'm trying to create a grid using a matplotlib function like imshow . From this array: [[ 1 8 13 29 17 26 10 4], [16 25 31 5 21 30 19 15]] I would like to plot the value as a color AND the text value itself (1,2, ...) on the same grid. This is what I have for the moment (I can only plot the color associated to each value): from matplotlib import pyplot import numpy as np grid = np.array([[1,8,13,29,17,26,10,4],[16,25,31,5,21,30,19,15]]) print 'Here is the array' print grid fig1, (ax1, ax2)=

Set two matplotlib imshow plots to have the same color map scale

跟風遠走 提交于 2019-12-03 06:31:17
I am trying to plot to fields with the same scale. The upper image values are a 10 times higher than the one bellow, but they turn out to be the same color in the imshow. How can I set both to have the same scales in colours? I added the code I am using bellow the image.. def show_field(field1,field2): fig = plt.figure() ax = fig.add_subplot(2, 1, 1) ax.imshow(field1,cmap=plt.cm.YlGn) ax.set_adjustable('box-forced') ax.autoscale(False) ax2 = fig.add_subplot(2, 1, 2) ax2.set_adjustable('box-forced') ax2.imshow(field2,cmap=plt.cm.YlGn) ax2.autoscale(False) plt.show() First you need to define the

Plotting at full resolution with matplotlib.pyplot, imshow() and savefig()?

≡放荡痞女 提交于 2019-12-03 05:47:01
I have a medium-sized array (e.g. 1500x3000) that I want to plot at scale since it is an image. However, the vertical and horizontal scales are very different. For simplification let say that there is one meter/row and 10/column. The plot should then produce an image which is c. 1500x30000. I use the kwarg extent for the scales and aspect = 1 to avoid deformation. Either by using the plotting windows (QT4) and imshow() or by using savefig(), I never succeeded in producing the image at scale and at full resolution. I have looked to many proposed solutions as indicated in here , here , or here

Matplotlib : display array values with imshow

谁说我不能喝 提交于 2019-12-02 22:37:11
I'm trying to create a grid using a matplotlib function like imshow . From this array: [[ 1 8 13 29 17 26 10 4], [16 25 31 5 21 30 19 15]] I would like to plot the value as a color AND the text value itself (1,2, ...) on the same grid. This is what I have for the moment (I can only plot the color associated to each value): from matplotlib import pyplot import numpy as np grid = np.array([[1,8,13,29,17,26,10,4],[16,25,31,5,21,30,19,15]]) print 'Here is the array' print grid fig1, (ax1, ax2)= pyplot.subplots(2, sharex = True, sharey = False) ax1.imshow(grid, interpolation ='none', aspect = 'auto

Align subplot with colorbar

十年热恋 提交于 2019-12-02 17:33:47
问题 I am trying to share the x-axis of a imshow that have to be square and a classique plot: the imshow has to be square with a colorbar the plot bellow should share the same axis (or at least look like align with the imshow) I spent two days on it, and now I am crazy. Did someone know how to align them ? The code used to produce the image is bellow. def myplot( Nbin=20 ): X = np.random.rand(1000) Y = np.random.rand(1000) h2, yh2, xh2 = np.histogram2d( Y, X, bins=[Nbin,Nbin] ) h1, xh1 = np

imshow() displays a white image for a grey image

爱⌒轻易说出口 提交于 2019-12-02 10:54:39
问题 I have computed an image with values between 0 and 255. When I use imageview(), the image is correctly displayed, in grey levels, but when I want to save this image or display it with imshow, I have a white image, or sometimes some black pixels here and there: Whereas with imageview(): Can some one help me? 回答1: Matlab expects images of type double to be in the 0..1 range and images that are uint8 in the 0..255 range. You can convert the range yourself (but change values in the process), do

smoothing imshow plot with matplotlib [duplicate]

≡放荡痞女 提交于 2019-12-02 07:26:35
This question already has an answer here: How to 'turn off' blurry effect of imshow() in matplotlib? 2 answers I am plotting a density of counts with imshow from matplotlib.pyplot but I'd like to have a smoother plot. Can I apply any filter on this? Try using the interpolation argument: ax.imshow(grid, interpolation=interp_method) matplotlib demo matplotlib api If you manually want to handle how strong the filter is you could do something along the lines of (scipy.ndimage has a lot of filters) from scipy.ndimage.filters import gaussian_filter arr=np.zeros((20,20)) arr[0,:]=3 arr[0,0]=20 arr[19

The difference between uint8 and double images when using imshow

不想你离开。 提交于 2019-12-02 07:04:55
The following code snippet results a double image . f = imread('C:\Users\Administrator\Desktop\2.tif'); h = double(f); figure; imshow(h); whereas, this other code snippet results a uint8 image . f = imread('C:\Users\Administrator\Desktop\2.tif'); figure; imshow(f); While displaying these two figures, the displayed results of these two images using imshow are different, but what is the reason behind this difference? Images of type double are assumed to have values between 0 and 1 and uint8 images are assumed to have values between 0 and 255. Since your double data contains values between 0 and