Questions tagged [imshow]

The imshow is a function from the matplotlib library that displays an image on the axes.

The is a function from the library that displays an image on the axes.

References:

See also:

806 questions
6
votes
2 answers

How to remove gaps between image subplots

Inspired by this question, I've been trying to get images plotted without gaps. In my toy example I have four images that I want to place in two rows. They have different shapes: different number of rows, same number of columns. Despite the…
Daniel
  • 11,332
  • 9
  • 44
  • 72
6
votes
3 answers

scipy.misc.imshow RuntimeError('Could not execute image view')

I am testing scipy.misc.imshow and I got RuntimeError: Could not execute image viewer. I am using Python3.4 and running it on CentOS 7. import scipy.misc img = scipy.misc.imread('Data/cat.jpg') assert len(img.shape) == 3 img_resized =…
chenfei
  • 734
  • 1
  • 9
  • 19
6
votes
1 answer

adding line plot to imshow and changing axis marker

I have made the attached plot using the following codes: a = 1 theta = np.linspace(0,2*np.pi,101) x = np.linspace(-3*a,3*a,1001, dtype='complex') y = np.linspace(-3*a,3*a,1001, dtype='complex') X,Y = np.meshgrid(x,y) # come manipulations with V #…
Physicist
  • 2,848
  • 8
  • 33
  • 62
6
votes
1 answer

Basemap Heat error / empty map

I am trying to plot a scattered heat map on a defined geo location. I can very well plot a normal scattered map with no background but I want to combine it with a given lat and lon. I get the following empty map. Input Input: col[2] and col[3] are…
user3964336
5
votes
0 answers

Is there a way to add discrete labels to plotly imshow images

I am using plotly to show an image using fig=px.imshow(img) I would like it to have a discret legend similar to the ones in the pie chart or the bar chart: fig2 = px.pie(df, values=df[0],names=df.index,color =df.index, color_discrete_map=…
5
votes
1 answer

Assign specific colors to values of an array when plotting it using imshow without creating a secondary array

I have a 2D NumPy array containing binary values (0 and 1) +1 additional value (-999) representing "no data". Here's a dummy example: import numpy as np arr = np.random.randint(2, size=(100,)) # this no-data value has to be large compared to the…
swiss_knight
  • 5,787
  • 8
  • 50
  • 92
5
votes
1 answer

Changing a color for a value in Imshow

I am a beginner using Python graphs, and I have a question about the matplotlib.pyplot.imshow function. My goal is to model the expansion of an oil spill in the sea by using the method of the random walk in a grid made of a list of lists. Then, I…
MelindaP
  • 51
  • 3
5
votes
1 answer

add text on plt.imshow

I have two ndarrays: Mat, labels Currently I display Mat: plt.imshow(Mat, cmap='gray', vmin=0, vmax=1, interpolation='None') labels has the same shape as Mat, and lables[(i,j)] contains a label of Mat[(i,j)]. How can I show the label on each pixel?
obar
  • 357
  • 6
  • 17
5
votes
1 answer

Matplotlib center/align ticks in imshow plot

I have been trying to center the x and y ticks of my imshow but without success. The desired yticks should be: [ 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000] and xticks: [ 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55] but…
seralouk
  • 30,938
  • 9
  • 118
  • 133
5
votes
1 answer

Matplotlib / Imshow / transparent layer everywhere but certain points

I try to plot a layer on an imshow. This layer is based on a matrix where every values are equals to 0 but some specific pixels are equals to 1. If I use the alpha parameter, I'm loosing mycolor as well... How can I have 0% transparency where I…
lelorrain7
  • 315
  • 5
  • 13
5
votes
1 answer

How to draw cell borders in imshow

I have a small 2d vector to display: import matplotlib.pyplot as plt import numpy as np img = np.random.rand(4,10) plt.imshow(img, cmap='Reds') As folllow: But now I want to mark a specific cell, in order to focus the reader on that cell. Because…
Matthias
  • 1,055
  • 2
  • 14
  • 26
5
votes
1 answer

cv2.imshow() does not work inside a custom function

OpenCV imshow function seems to work outside a function but not inside that function (and I don't think the answer is waitKey()). Why is this happening and how can I solve it? I am learning 2D Gabor wavelets. For experimenting and observing I first…
alpersunter
  • 93
  • 1
  • 7
5
votes
2 answers

A faster refresh rate with plt.imshow

I'd like to display some images while doing a numpy computation: import numpy as np import matplotlib.pyplot as plt plt.ion() # Turn the interactive mode on. for i in range(100): A = np.random.randn(10,10) plt.imshow(A) …
Basj
  • 41,386
  • 99
  • 383
  • 673
5
votes
2 answers

Matplotlib - sequence is off when using plt.imshow()

I write a dog-classifier in a Jupyter notebook that, every time a dog is detected in an image, should show the image and print some text describing it. Somehow, the images are always displayed after all the text was printed, no matter in which order…
beinando
  • 477
  • 4
  • 18
5
votes
1 answer

How do I overlay two .fits images each with different WCS / resolutions?

I'm trying to plot contours from one image of an object, let's say in band A, on top of a lower resolution image of that same object, let's say in band Z. Both images are in large fits files, so I have to create a 2D cutout of each. However, the…
astrobrown
  • 51
  • 1
  • 3