imshow

A faster refresh rate with plt.imshow

南楼画角 提交于 2019-12-01 07:14:04
问题 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) plt.pause(0.001) # do some other numpy computations here (they take < 1 ms) Instead of displaying the images quickly, it is rather slow . I'm not asking for 100 frames per second, but I thought 30 fps would be possible, but it's not: after a few iterations, I'm close to 2 fps

Reflect event handling on multiple subplots

六眼飞鱼酱① 提交于 2019-12-01 06:30:17
I am trying to create a interactive plot containing 4 subplots. Ideally clicking on one of the subplots would result the same (mirror click) in the rest of them. Until now I was only able to individually click on them and get the specific data using mpldatacursor. Here in this plot one click event would result in all 4 graphs displaying the corresponding data for x,y,z: import matplotlib.pyplot as plt import numpy as np from mpldatacursor import datacursor fig, ((ax1,ax2),(ax3,ax4)) = plt.subplots(nrows=2, ncols=2,sharex=True, sharey=True, figsize=(60, 20)) plt.subplots_adjust(wspace=0.08,

matplot imshow add label to each color and put them in legend [duplicate]

瘦欲@ 提交于 2019-12-01 06:16:12
问题 This question already has answers here : How to add legend to imshow() in matplotlib (4 answers) Closed 3 years ago . I want to show an image like below (copied from here) in matplotlib But I want to label each color and put them on a legend on the side, is there way to do that please? 回答1: I suppose putting a legend for all values in a matrix only makes sense if there aren't too many of them. So let's assume you have 8 different values in your matrix. We can then create a proxy artist of the

Reflect event handling on multiple subplots

こ雲淡風輕ζ 提交于 2019-12-01 04:24:42
问题 I am trying to create a interactive plot containing 4 subplots. Ideally clicking on one of the subplots would result the same (mirror click) in the rest of them. Until now I was only able to individually click on them and get the specific data using mpldatacursor. Here in this plot one click event would result in all 4 graphs displaying the corresponding data for x,y,z: import matplotlib.pyplot as plt import numpy as np from mpldatacursor import datacursor fig, ((ax1,ax2),(ax3,ax4)) = plt

Getting error - 'could not find a writer'while giving imshow, imwrite command opencv

本秂侑毒 提交于 2019-11-30 19:11:31
I am a beginner at opencv and python. I have just installed opencv2.4.9 and enthought canopy-32bit. I am getting error for the following: import cv2 image = cv2.imread('Lena.jpg') cv2.imwrite('Mypic',image) This is what I get: c:\users\nam\appdata\local\temp\tmpokspbt.py in <module>() 3 4 image = cv2.imread('Lena.jpg') ----> 5 cv2.imwrite('Mypic',image) error: ..\..\..\..\opencv\modules\highgui\src\loadsave.cpp:275: error: (-2) could not find a writer for the specified extension in function cv::imwrite_ you need to give an extension to imwrite(), so it knows, how to save(compress) it. cv2

how do I redraw an image using python's matplotlib?

南楼画角 提交于 2019-11-30 12:46:12
What I am trying to do seems to be fairly straightforward, but I'm having a heck of a time trying to get it to work. I am simply trying to draw an image using imshow and then re-draw it periodically as new data arrives. I've started out with this: fig = figure() ax = plt.axes(xlim=(0,200),ylim=(0,200)) myimg = ax.imshow(zeros((200,200),float)) Then I'm assuming I can call set_data like this to update the image: myimg.set_data(newdata) I've tried many other things, for example I've called ax.imshow(newdata) instead or I've tried using figure.show() after set_data() . You can simply call figure

How to add legend to imshow() in matplotlib

走远了吗. 提交于 2019-11-30 08:39:08
问题 I am using matplotlib In plot() or bar() , we can easily put legend, if we add labels to them. but what if it is a contourf() or imshow() I know there is a colorbar() which can present the color range, but it is not satisfied. I want such a legend which have names(labels). For what I can think of is that, add labels to each element in the matrix, then ,try legend(), to see if it works, but how to add label to the element, like a value?? in my case, the raw data is like: 1,2,3,3,4 2,3,4,4,5 1

Contour/imshow plot for irregular X Y Z data

徘徊边缘 提交于 2019-11-30 06:31:07
问题 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 for measurements and X and Y look are irregularly spaced. Many thanks, len(X)=100 len(Y)=100 len(Z)=100 回答1: Does plt.tricontourf(x,y,z) satisfy your requirements? It will plot filled contours for irregularly spaced data (non-rectilinear grid). You

Adjusting gridlines and ticks in matplotlib imshow

隐身守侯 提交于 2019-11-30 03:03:35
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 the label in the same location and b) add gridlines between the pixel boundaries? import matplotlib.pyplot as plt import numpy as np im = plt.imshow(np.reshape(np.random.rand(100), newshape=(10,10)), interpolation='none', vmin=0, vmax=1, aspect='equal'); ax = plt.gca(); ax.set_xticks(np.arange(0, 10, 1)); ax.set_yticks(np.arange(0, 10, 1)); ax.set

Getting error - 'could not find a writer'while giving imshow, imwrite command opencv

戏子无情 提交于 2019-11-30 02:58:33
问题 I am a beginner at opencv and python. I have just installed opencv2.4.9 and enthought canopy-32bit. I am getting error for the following: import cv2 image = cv2.imread('Lena.jpg') cv2.imwrite('Mypic',image) This is what I get: c:\users\nam\appdata\local\temp\tmpokspbt.py in <module>() 3 4 image = cv2.imread('Lena.jpg') ----> 5 cv2.imwrite('Mypic',image) error: ..\..\..\..\opencv\modules\highgui\src\loadsave.cpp:275: error: (-2) could not find a writer for the specified extension in function