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
318
votes
15 answers

Removing white space around a saved image

I need to take an image and save it after some process. The figure looks fine when I display it, but after saving the figure, I got some white space around the saved image. I have tried the 'tight' option for savefig method, did not work either. The…
Ahmet Tuğrul Bayrak
  • 3,466
  • 2
  • 15
  • 27
268
votes
11 answers

Set Matplotlib colorbar size to match graph

I cannot get the colorbar on imshow graphs like this one to be the same height as the graph, short of using Photoshop after the fact. How do I get the heights to match?
Elliot
  • 5,211
  • 10
  • 42
  • 70
192
votes
11 answers

How to display an image

I tried to use IPython.display with the following code: from IPython.display import display, Image display(Image(filename='MyImage.png')) I also tried to use matplotlib with the following code: import matplotlib.pyplot as plt import…
FiReTiTi
  • 5,597
  • 12
  • 30
  • 58
145
votes
2 answers

How to display multiple images in one figure

I am trying to display 20 random images on a single Figure. The images are indeed displayed, but they are overlaid. I am using: import numpy as np import matplotlib.pyplot as plt w=10 h=10 fig=plt.figure() for i in range(1,20): img =…
bkr879
  • 2,035
  • 2
  • 15
  • 23
125
votes
3 answers

Change values on matplotlib imshow() graph axis

Say I have some input data: data = np.random.normal(loc=100, scale=10, size=(500,1,32)) hist = np.ones((32, 20)) # initialise hist for z in range(32): hist[z], edges = np.histogram(data[:, 0, z], bins=np.arange(80, 122, 2)) I can plot it using…
Lee
  • 29,398
  • 28
  • 117
  • 170
117
votes
2 answers

Imshow: extent and aspect

I'm writing a software system that visualizes slices and projections through a 3D dataset. I'm using matplotlib and specifically imshow to visualize the image buffers I get back from my analysis code. Since I'd like to annotate the images with plot…
ngoldbaum
  • 5,430
  • 3
  • 28
  • 35
59
votes
5 answers

Display multiple images in subplots

How do I use the matlib function plt.imshow(image) to display multiple images? For example my code is as follows: for file in images: process(file) def process(filename): image = mpimg.imread(filename)
zooter
  • 2,128
  • 1
  • 13
  • 23
52
votes
2 answers

Matplotlib imshow - Change default colour normalisation

I have consistently had problems with my colour maps when using imshow; some colours seem to just become black. I have finally realised that imshow seems to, by default, normalise the matrix of floating point values I give it. I would have expected…
oLas
  • 1,171
  • 1
  • 9
  • 17
51
votes
5 answers

Adjusting gridlines and ticks in matplotlib imshow

I'm trying to plot a matrix of values and would like to add gridlines to make the boundary between values clearer. Unfortunately, imshow decided to locate the tick marks in the middle of each voxel. Is it possible to a) remove the ticks but leave…
Joe Bathelt
  • 5,459
  • 2
  • 15
  • 14
43
votes
2 answers

Top label for matplotlib colorbars

By default, matplotlib would position colorbar labels alongside the vertical colorbars. What is the best way to force the label to be on top of a colorbar? Currently my solution needs adjusting labelpad and y values depending on size of the…
Vlas Sokolov
  • 3,733
  • 3
  • 26
  • 43
40
votes
7 answers

Image is not displaying in Google Colab while using imshow()

I am working on a project which requires functions from OpenCV to plot images. I am trying to display image using the below code in Google Colab. But nothing shows up in the output. Can anybody help me with this? %pylab notebook import cv2 testim =…
Alankrit
  • 658
  • 1
  • 6
  • 17
37
votes
2 answers

Matplotlib : display array values with imshow

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…
Ludovic Aphtes
  • 385
  • 1
  • 3
  • 8
33
votes
3 answers

Python - OpenCV - imread - Displaying Image

I am currently working on reading an image and displaying it to a window. I have successfully done this, but upon displaying the image, the window only allows me to see a portion of the full image. I tried saving the image after loading it, and it…
Sinjin Forde
  • 343
  • 1
  • 4
  • 6
28
votes
6 answers

Contour/imshow plot for irregular X Y Z data

I have data in X, Y, Z format where all are 1D arrays, and Z is the amplitude of the measurement at coordinate (X,Y). I'd like to show this data as a contour or 'imshow' plot where the contours/color represent the the value Z (amplitude). The grid…
Scientist
  • 371
  • 2
  • 4
  • 5
25
votes
2 answers

How can I generate and display a grid of images in PyTorch with plt.imshow and torchvision.utils.make_grid?

I am trying to understand how torchvision interacts with mathplotlib to produce a grid of images. It's easy to generate images and display them iteratively: import torch import torchvision import matplotlib.pyplot as plt w =…
Jon Middleton
  • 363
  • 1
  • 3
  • 8
1
2 3
53 54