Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

Adding colorbar to imshow in matplotlib makes plot stick to the right [duplicate]

When i added a colorbar to an imshow plot within pyside6 application, the whole plot sticks to the right (see picture). image of matrix that stick to the right When there is no colorbar, the plot is ...
Jano Labuda's user avatar
0 votes
0 answers
19 views

Imshow, colormesh and contourf with MODIS data

my problem is that the pcolormesh make the right thing with interplation artefacts and imshow lose the lat/lon grid as shown in the image. is there a way to get an mesh image without artefacts? Here ...
Samoth K's user avatar
2 votes
1 answer
50 views

Syncing matplotlib imshow coordinates

I'm trying to create an image using networkx, save that image to use later, and then overlay a plot over top of it later. However, when I try to load the image in and make new points, the scale seems ...
Amanda's user avatar
  • 454
3 votes
1 answer
76 views

wordcloud with 2 background colors

I generated this on wordcloud.com using one of the "themes". I'd like to be able to do this with the python wordcloud library, but so far all I can achieve is a single background color (so ...
nettie's user avatar
  • 692
0 votes
1 answer
23 views

python to contour plot three different densities in 2D

I wanted to plot three 2d densities of n0, n1 and n2 using imshow() command in matplotlib and show their colorbars. The densities are quite different and even when i normalize them the final image is ...
Hossein's user avatar
-1 votes
1 answer
225 views

OpenCV IMSHOW error when running even when provided all parameters

I am using OpenCV for my program but I am getting an error during the cv2.imshow command. My program is trying to process an MP4 video and crop the licence plates from the cars involved. I am ...
su542sa's user avatar
0 votes
0 answers
71 views

How to automate placement of fig.suptitle properly when displaying wide images with imshow in matplotlib?

The issue is that fig.suptitle and ax.imshow (with wide images) do not work well together. I understand that there are some aspect ratio (or something) hurdles to overcome due to the image being wide ...
Yolkions's user avatar
0 votes
1 answer
46 views

how to inlay a matplotlib imshow inside another

Here's a reprex import urllib # to retrieve the file from the internet from PIL import Image # to interpret the bytes as an image import numpy as np # to work with arrays of numbers (the image is an ...
Joe's user avatar
  • 903
0 votes
1 answer
75 views

How to achieve such picture effect using python?

I'm drawing a heat distribution map using python. But I found that the pixels of other people’s pictures looked like the first, and mine looked like the second. It seems that other people's pictures ...
Hanjiahe's user avatar
0 votes
1 answer
55 views

Heatmap plot with weirdly shaped data

so I am trying to create a heatmap plot for x, y data that are shaped as following: xs, ys, corrs = [], [], [] for x in np.linspace(0.1,5,25): xs.append(x) for y in np.linspace(0.01,x,25): ...
Roberto Corral's user avatar
0 votes
0 answers
35 views

"Imshow" not showing in top of "scatter"

I am willing to plot two different things in one image. I want to see the evolution of some probabilities in time, together with a cone which limits their expansion. I plot the first one using scatter,...
Mikel Puy's user avatar
0 votes
0 answers
25 views

How can I force plots to be the same size when the figsize setting does nothing in pyplot? [duplicate]

I wrote the following code: import pandas as pd import numpy as np import matplotlib.pyplot as plt import random symetricArr=[[random.random() for i in range(100)] for j in range(100)] asymetricArr=[[...
Jamie's user avatar
  • 782
-5 votes
1 answer
396 views

how to use cv2.imshow()?

Code: cv2.imshow('E:\Open_CV\opencv\images', img) error: error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1272: error: (-2:Unspecified error) The function ...
Ishwarya S's user avatar
0 votes
0 answers
85 views

The kernel appears to have died. It will restart automatically. whenever i try to run the plt.imshow() and plt.show() function in jupyter notebook

import cv2 import matplotlib.pyplot as plt import tensorflow as tf from tensorflow.keras.preprocessing.image import load_img, img_to_array #load model using tensorflow model = tf.keras.models....
ZUBEDA NAMBOZO's user avatar
2 votes
0 answers
202 views

Corrupted image when saving imshow as PDF with matplotlib

I have been trying to save an imshow figure as a PDF, but when I try to open it up in my PDF reader (Acrobat Reader DC) it says "Insufficient data for an image" and refuses to display the ...
Gustaf's user avatar
  • 21
0 votes
0 answers
43 views

Heatmaps with imshow not displaying x axis properly

I am attempting to create a heatmap using data from an Excel file. The excel file has multiple sheets and in each sheet there is a column with 'Z Score Times', which are the times I want on the X axis ...
Lik_pole's user avatar
0 votes
0 answers
153 views

Google Colab: On-click interactive plots not working

I'm trying to use this snippet, which works as intended locally, in Google Colab. The snippet basically set to NaN a pixel value on click. Google Colab does show correctly the image but if I click on ...
Enki's user avatar
  • 1
0 votes
1 answer
90 views

imshow defaults to inverted y axis, can't be flipped using invert_yaxis [duplicate]

Whenever I generate a graph in matplotlib, the axis seems to be inverted. As an example, I created a figure from an array of 0s: dims = [100,100] square = np.zeros(dims) plt.imshow(square) This ...
Amy M's user avatar
  • 23
0 votes
1 answer
102 views

TypeError when using cv2.rectangle in Python OpenCV

this is my code colors = [(245,117,16), (117,245,16), (16,117,245)] def prob_viz(res, actions, input_frame, colors): output_frame = input_frame.copy() for num, prob in enumerate(res): ...
Sivani's user avatar
  • 1
-2 votes
1 answer
89 views

opencv non-active application, window Error when i tried "imshow()"

my xcode error image [CODE] #include <iostream> #include <sstream> #include <opencv2/opencv.hpp> using namespace std; using namespace cv; int main(){ cout << "openCV ...
signalsigram's user avatar
1 vote
0 answers
42 views

Washed out colors when reproducing 2017 figure [duplicate]

In April 2017 I used the following code to produce the following figure: plt.clf() plt.imshow(result, cmap = 'hot', aspect = 'equal') plt.colorbar() plt.axis('off') plt.savefig('p1....
pente's user avatar
  • 11
0 votes
0 answers
143 views

Adding color bar to 1D heatmap [duplicate]

I have found an excellent answer from Creating a 1D heat map from a line graph but I need a color reference/side bar to show what numerical values each color represents. There is a comment asking this ...
con's user avatar
  • 6,063
0 votes
0 answers
111 views

How to read .png file with matplotlib to not lack information? [duplicate]

I have created a png file with matplotlib. When opened in a Viewer it shows all the parts of the graph. However, when reading the image with matplotlib, only the coordinate system is shown, not the ...
Tim's user avatar
  • 53
0 votes
2 answers
350 views

Make heatmap have the same axes size [duplicate]

This is a sample code. Here, xlim = (0,2) and ylim = (0,5). I want to keep it that way (different limits) while figuring out a way to make the x-axis and y-axis the same size. import matplotlib.pyplot ...
Anish Nahar's user avatar
0 votes
0 answers
104 views

imshow uses a seemingly random background color

I am trying to use imshow(), with categorical data. But I cannot reliably control the colors used. This is my code (inspired in the solution provided here from random import choice import matplotlib....
onlycparra's user avatar
0 votes
2 answers
72 views

Reduce space between subplots [duplicate]

Do you know how to reduce the space between these plots? fig, axs = plt.subplots(2) axs[0].imshow(np.random.randint(0,15,size=(70,714))) axs[1].imshow(np.random.randint(0,15,size=(70,714))) plt.show() ...
Sebastian Pinilla's user avatar
3 votes
1 answer
120 views

imshow with x-axis as log scale is not equally-spaced

I am using pcolor to generate the following plot (code below). It has a colorbar in log scale and the x-values are in log-scale too. The problem is that the rectangles in this plot have different ...
Physics_Student's user avatar
0 votes
0 answers
24 views

plt.savefig behaviour in eps mode for nan type using imshow [duplicate]

I am trying to save an image using plt.imshow and plt.savefig by inputting a certain 2D array that happens to contain NaNs. When I call plt.show() the NaNs map to white but when saved to an eps file ...
maxxpinse's user avatar
1 vote
1 answer
753 views

How to plot a FITS image with world coordinates of RA DEC on galactic coordinates

I use the following code to plot a fits image with ra dec wcs onto a galactic coordinate: import matplotlib.pyplot as plt from astropy.io import fits from astropy.wcs import WCS fig = plt.figure() ...
ming's user avatar
  • 11
0 votes
1 answer
116 views

imshow doesn't show the correct RGB values [duplicate]

I'm confused why my canvas class produce only 255 colors that is colors that are the pure red in this case. Although my code specifies darker tones of red for the colors of the different pixels, the ...
cabbage_queen's user avatar
0 votes
2 answers
466 views

How to adjust the scale of imshow plots to keep y axis constant in subplot?

I have several numpy arrays I am plotting with imshow. They all have the same vertical size but different horizontal sizes. I would like to adapt the aspect to be non-scalar and proportional to my ...
Bastien's user avatar
2 votes
2 answers
502 views

Plotting a Pandas DataFrame with RGB values and coordinates

I have a pandas DataFrame with the columns ["x", "y", "r", "g", "b"] where x and y denote the coordinates of a pixel and r, g, b denote its RGB value. ...
YPOC's user avatar
  • 652
0 votes
1 answer
190 views

Align axes of imshow with axes of graph in the picture

I would like to plot on top of a picture of a graph from a paper. I plot the picture with a simple imshow: import matplotlib.pyplot as plt import matplotlib.image as mpimg img = mpimg.imread('...
theWrongAlice's user avatar
0 votes
1 answer
514 views

Plot a Python Matplotlib imshow (heatmap) from a dictionary of lists

I have a dictionary of lists: dictA = {"A": [1,2,3], "B": [4,5,6], "C": [7,8,9]} I want to display the data as a heatmap using the Matplotlib imshow. A, B and C run ...
Anthony Nash's user avatar
  • 1,089
-2 votes
1 answer
292 views

Matplotlib imshow is ignoring cmap, vmin, vmax for ax.imshow subplots [closed]

I am trying to make subplots of small images of data and I am finding it completely impossible to adjust the cmap/vmin/vmax for any of these images. No matter what I can't figure out how to change the ...
theevilnerd42's user avatar
0 votes
1 answer
56 views

How can I draw a contour for a piecewise function with pyplot.imshow

My function is z = (x - 1) **10 + 5*(x - 1)**5*(y - 1)**5 + (y - 1)**10. However, the contour can't show clear about negative value because of large positive value. So I just need to show positive ...
auntyellow's user avatar
  • 2,573
0 votes
1 answer
20 views

How to extract specific condition values in python np.array without changing the shape

Range value of my image data is -0.3 ~ 28.25 and image shape was like this. D1 = data1 D1 = D1[0, 0, ...] D1 = data1 -> shape : (1,1,512,512) D1 = D1[0, 0, ...] -> shape: (512,512) Because, ...
vintz's user avatar
  • 13
0 votes
0 answers
58 views

I wonder why range of spectral index map by imshow is different with theoretical value

From fits file I got D1 and D2 data. min and max value of D1 and D2 is like this Since I'm trying to get spectral index value which formula is like this I made my code like this [D1 is flux data ...
vintz's user avatar
  • 13
0 votes
1 answer
108 views

How to create FuncAnimation (matplotlib) animation from plt.imshow and animate text in double for loop?

LONG POST: I know many posts are available on StackOverflow on a similar topic, but none worked for me so far. The animation is either not fast enough, or the text is animated (not how I want), but ...
Rao208's user avatar
  • 147
0 votes
0 answers
61 views

opencv imshow() didnt work on windows 10,but works on mac why?

import cv2 img = cv2.imread('lena.jpg',1) cv2.imshow('image',img) cv2.waitKey(0) cv2.destroyAllWindows() cv2.waitKey(1) No image is displayed while running the program above on windows10 (python 3.10,...
Jiya Jiya's user avatar
0 votes
1 answer
170 views

matplotlib, imshow not having witespace between axes in grid plot

I want a grid figure with m rows and n columns to be displayed sharing both x and y axis between subplots, and no whitespace between them. This is easy to achieve with simple plot in matplotlib, as ...
fffff's user avatar
  • 93
0 votes
0 answers
192 views

How to create a logarithmic scale for the x and y axis of a heat map with Python

Im having some issues creating a heatmap using plt.imshow() with specific axes that I want to display in a logarithmic scale. I tried different methods, but the image doesn't seem to work when i try ...
IC_S's user avatar
  • 1
0 votes
1 answer
92 views

Why isn't imshow displaying correctly when using custom ticks?

I am trying to plot heatmap with average values with x and y axes denote physical parameters. import csv import matplotlib.pyplot as plt from scipy import stats import numpy as np #......................
Parag's user avatar
  • 41
0 votes
2 answers
329 views

Draw contour around binary mask image in Python

I have a binary mask of the Antarctic ice sheet with pixels 0 = no ice sheet and 1 = ice sheet. How can I create a contour around the ice sheet pixels so that it creates an edge around the mask using ...
user5618251's user avatar
0 votes
1 answer
157 views

imshow with twinx that is also aligned with tiles

There is a thread where the question was to add an automatically labelled twinx to Matplotlib's imshow. The result was: However, I would like the ticks on the second y-axis to be 1. manually settable ...
Mew's user avatar
  • 415
0 votes
0 answers
85 views

use of matplotlib.imshow() without "Clipping input data to the valid range"

I'm using matplotlib.imshow() with students to learn basic image processing. But if a student make an error, i would like python to show a warning instead of correcting it automatically. For exemple : ...
Nils RICHARD's user avatar
1 vote
1 answer
79 views

How to plot multiple color lists from pandas in subplots with imshow

I'm looking to visualize the colors of music releases per genre. I'm using the below code. However, the issue is that it's not showing the colors grouped per genre on individual rows. It seems like it'...
jsb92's user avatar
  • 97
3 votes
1 answer
731 views

plt.imshow() of a single color image showing as black

I am trying to show a light-gray image using plt.imshow(), but the image turns out black. I tried: import matplotlib.pyplot as plt import numpy as np test_image = np.zeros((3871, 2484)) test_image....
roydbt's user avatar
  • 101
0 votes
0 answers
46 views

Why does my matplotlib-plotted image looks almost completely white? [duplicate]

I am trying to plot .npy-files containing 3d arrays (values in range from -90 to 315) with matplotlib and I am constantly getting an almost completely white image, with only a few colorful spots. This ...
liz's user avatar
  • 25
1 vote
0 answers
76 views

How to change figsize keeping imshow aspect='equal'?

Is there a way to change the figsize of a matplotlib figure after drawing an image with ax.imshow()? I have a numpy array of size (10, 100) (let's say) and I want to plot it with ax.imshow(). It ...
da_jack's user avatar
  • 11

1
2 3 4 5
17