imshow

Plotting a 2d contour plot in python with sparse data

最后都变了- 提交于 2020-01-05 07:01:26
问题 I have some output data from an ocean circulation model (MITgcm). It is an idealised channel (Cartesian) so the geometry is not confusing, luckily. I'd like to plot some of the fields (velocity, temperature etc.) in the y-z plane. The simulation domain involves 30 vertical layers where each layer is an 800x400 y-x grid. I have each of the fields stored in numpy arrays with shape (30, 800, 400) going z,y,x respectively. I can easily plot x-y plane slices for the 30 vertical levels. I can do

matplotlib imshow - default colour normalisation

守給你的承諾、 提交于 2019-12-27 17:37:51
问题 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

Image not displaying with imshow() OpenCV

倾然丶 夕夏残阳落幕 提交于 2019-12-25 08:38:04
问题 I'm getting a weird issue (but no error) when loading in an image and trying to display it. Here's the code I'm using: import numpy as np import cv2 # I'm using the full-path in the actual document img = cv2.imread('shapes.jpg') gray = cv2.imread('shapes.jpg',0) #not displaying anything currently cv2.imshow('gray', img) cv2.waitKey(0) cv2.destroyAllWindows() What I do get is the top part of a window. When using cv2.namedWindow('gray', cv2.WINDOW_NORMAL) , I'm able to maximize the image and I

Updating one “pixel” with imshow

╄→гoц情女王★ 提交于 2019-12-25 01:09:05
问题 I am simulating an IsingModel with the Metropolis-Algorithm in Fortran and want to visualize the steps with python as a movie. I have a 100x100 grid with values from {-1,1} and performe about 1_000_000 steps/changes on the grid. I thought i could plot/animate each step with the matplotlib function pyplot.imshow as i needed some snapshots/images also. However i cant find an option to just update the "pixel" which was changed the last step. And set_array(...) is reaaaallllyyy slow... Is there a

opencv imshow with waitKey too slow on Mac OS X 10.10.2 (using c++)

ぐ巨炮叔叔 提交于 2019-12-24 04:34:07
问题 I am using opencv c++ on Mac OS X 10.10.2 to process video frames and display them. The performance of imshow with waitKey to display the video is extremely slow. I have the following code which displays HD (1920x1080) grayscale frames correctly, except that it runs about 10 times too slow (i.e. 2 to 3 frames per second instead of 30 frames per second). cv::Mat framebuf[TEST_COUNT]; //--- Code here to allocate and fill the frame buffer with about 4 seconds of video. This part works correctly.

Why is plt.imshow so much quicker than plt.pcolor ?

女生的网名这么多〃 提交于 2019-12-24 00:43:51
问题 I am trying to figure out as much data visualization tools as I can from 2D matrices (bonus points to any other good methods for looking at 2D matrices). I generate a lot of heatmaps, where I've been told pcolor is the way to go (I now use seaborn ). Why is plt.imshow SO much quicker than plt.pcolor when they are doing really similar operations? def image_gradient(m,n): """ Create image arrays """ A_m = np.arange(m)[:, None] A_n = np.arange(n)[None, :] return(A_m.astype(np.float)+A_n.astype

Basemap Heat error / empty map

本小妞迷上赌 提交于 2019-12-23 09:33:16
问题 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 the x and y co ordinates & Geo Location Lat: 19.997453 , Lon: 73.789802 000000000023 61.0 19.006113 73.009168 000000000054 65.0 19.009249 73.000342 000000000003 19.0 19.001051 73.000080 000000000012 20.0 19.009390 73.008638 000000000061 82.0 19

python imshow, set certain value to defined color

自古美人都是妖i 提交于 2019-12-22 08:26:02
问题 I have a RGB Image, which I plot with matplotlib.pyplot.imshow and it works fine. But now I want to change the plot, that where the value of the picture is e.g 1, the color of the plot should change to white at all this positions. Is there a way to do this? 回答1: Assuming that your image is a single-channel image rather than a three-channel image, the required task can be performed by defining a palette that maps indices (e.g. gray level intensities or picture values) into colors: import numpy

Plotting at full resolution with matplotlib.pyplot, imshow() and savefig()?

别来无恙 提交于 2019-12-20 18:14:14
问题 I have a medium-sized array (e.g. 1500x3000) that I want to plot at scale since it is an image. However, the vertical and horizontal scales are very different. For simplification let say that there is one meter/row and 10/column. The plot should then produce an image which is c. 1500x30000. I use the kwarg extent for the scales and aspect = 1 to avoid deformation. Either by using the plotting windows (QT4) and imshow() or by using savefig(), I never succeeded in producing the image at scale

smoothing imshow plot with matplotlib [duplicate]

怎甘沉沦 提交于 2019-12-20 04:18:12
问题 This question already has answers here : How to 'turn off' blurry effect of imshow() in matplotlib? (2 answers) Closed 4 years ago . I am plotting a density of counts with imshow from matplotlib.pyplot but I'd like to have a smoother plot. Can I apply any filter on this? 回答1: Try using the interpolation argument: ax.imshow(grid, interpolation=interp_method) matplotlib demo matplotlib api If you manually want to handle how strong the filter is you could do something along the lines of (scipy