imshow

How to completely remove the white space around a scatterplot?

风流意气都作罢 提交于 2019-11-27 03:45:54
问题 I am trying to plot a scatterplot over an image without having any white space around it. If I plot just the image as follows, then there is no white space: fig = plt.imshow(im,alpha=alpha,extent=(0,1,1,0)) plt.axis('off') fig.axes.axis('tight') fig.axes.get_xaxis().set_visible(False) fig.axes.get_yaxis().set_visible(False) but as I add a scatter plot over the image as follows: fig = plt.scatter(sx, sy,c="gray",s=4,linewidths=.2,alpha=.5) fig.axes.axis('tight') fig.axes.get_xaxis().set

matplotlib imshow - default colour normalisation

删除回忆录丶 提交于 2019-11-27 01:19:14
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 an array such as [[0,0.25],[0.5,0.75]] to display the appropriate colours from the map, corresponding to those absolute values but the 0.75 will be interpreted as a 1. In the extreme case, an N x N array of 0.2 (for example), would just produce one big black square, rather than whatever one would expect 0.2 to correspond to in the colour map

Use imshow of matplotlib.pylab with a python ide?

淺唱寂寞╮ 提交于 2019-11-26 23:35:47
问题 I tried to run example in photutil Everything works great except the line plt.imshow(image, cmap='gray_r', origin='lower') which does not raise an exception but no image is shown. I use the eric ide. 回答1: You need to call plt.show() afterwards. From the Matplotlib FAQ: When you want to view your plots on your display, the user interface backend will need to start the GUI mainloop. This is what show() does. It tells matplotlib to raise all of the figure windows created so far and start the

Python xticks in subplots

此生再无相见时 提交于 2019-11-26 19:08:08
问题 If I plot a single imshow plot I can use fig, ax = plt.subplots() ax.imshow(data) plt.xticks( [4, 14, 24], [5, 15, 25] ) to replace my xtick labels. Now, I am plotting 12 imshow plots using f, axarr = plt.subplots(4, 3) axarr[i, j].imshow(data) How can I change my xticks just for one of these subplots? I can only access the axes of the subplots with axarr[i, j] . How can I access plt just for one particular subplot? 回答1: There are two ways: Use the axes methods of the subplot object (e.g. ax

Imshow: extent and aspect

北城以北 提交于 2019-11-26 17:13:04
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 axes, I use the extent keyword that imshow supplies to map the image buffer pixel coordinates to a data space coordinate system. Unfortuantely, matplotlib doesn't know about units. Say (taking an artificial example) that I want to plot an image with dimensions of 1000 m X 1 km . In that case the extent would be something like [0, 1000, 0, 1] . Even

Creating intersecting images in matplotlib with imshow or other function

若如初见. 提交于 2019-11-26 14:18:07
问题 I have two 3-D arrays of ground penetrating radar data. Each array is basically a collection of time-lapse 2-D images, where time is increasing along the third dimension. I want to create a 3-D plot which intersects a 2-D image from each array. I'm essentially trying to create a fence plot. Some examples of this type of plot are found on these sites: http://www.geogiga.com/images/products/seismapper_3d_seismic_color.gif http://www.usna.edu/Users/oceano/pguth/website/so461web/seismic_refl

How to remove gaps between *images* in matplotlib?

删除回忆录丶 提交于 2019-11-26 12:33:01
问题 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 differences, they should fit in a single figure without gaps, as in the following illustration: When I try to get them together, though, setting plt.subplots_adjust(wspace=0, hspace=0) doesn\'t do the trick, because the images have different shapes. Here

update frame in matplotlib with live camera preview

廉价感情. 提交于 2019-11-26 11:19:08
问题 I am new to both Python and Matplotlib. My computer is connected to two usb cameras, and I intend to use the subplot(1,2,1) and subplot(1,2,2) in matplotlib to plot the frames from the two camera in time series. When I do this with my code, I either get only one frame plotted or get a black screen in the plotting area. My code look like below #import import cv2 import matplotlib.pyplot as plt #Initiate the two cameras cap1 = cv2.VideoCapture(0) cap2 = cv2.VideoCapture(1) #Capture the frames

matplotlib savefig performance, saving multiple pngs within loop

前提是你 提交于 2019-11-26 10:02:49
问题 I\'m hoping to find a way to optimise the following situation. I have a large contour plot created with imshow of matplotlib. I then want to use this contour plot to create a large number of png images, where each image is a small section of the contour image by changing the x and y limits and the aspect ratio. So no plot data is changing in the loop, only the axis limits and the aspect ratio are changing between each png image. The following MWE creates 70 png images in a \"figs\" folder

Matplotlib: how to make imshow read x,y coordinates from other numpy arrays?

≡放荡痞女 提交于 2019-11-26 09:59:25
问题 When you want to plot a numpy array with imshow , this is what you normally do: import numpy as np import matplotlib.pyplot as plt A=np.array([[3,2,5],[8,1,2],[6,6,7],[3,5,1]]) #The array to plot im=plt.imshow(A,origin=\"upper\",interpolation=\"nearest\",cmap=plt.cm.gray_r) plt.colorbar(im) Which gives us this simple image: In this image, the x and y coordinates are simply extracted from the position of each value in the array. Now, let\'s say that A is an array of values that refer to some