contour

Python: find contour lines from matplotlib.pyplot.contour()

放肆的年华 提交于 2019-11-26 12:22:04
问题 This question was migrated from Mathematica Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . I\'m trying to find (but not draw!) contour lines for some data: from pprint import pprint import matplotlib.pyplot z = [[0.350087, 0.0590954, 0.002165], [0.144522, 0.885409, 0.378515], [0.027956, 0.777996, 0.602663], [0.138367, 0.182499, 0.460879], [0.357434, 0.297271, 0.587715]] cn = matplotlib.pyplot.contour(z) I know cn contains the contour lines I want, but I

R interpolated polar contour plot

谁说我不能喝 提交于 2019-11-26 12:09:17
问题 I\'m attempting to script a contour polar plot in R from interpolated point data. In other words, I have data in polar coordinates with a magnitude value I would like to plot and show interpolated values. I\'d like to mass produce plots similar to the following (produced in OriginPro): My closest attempt in R to this point is basically: ### Convert polar -> cart # ToDo # ### Dummy data x = rnorm(20) y = rnorm(20) z = rnorm(20) ### Interpolate library(akima) tmp = interp(x,y,z) ### Plot

Plotting contours on an irregular grid

柔情痞子 提交于 2019-11-26 10:22:44
I have gone through pages and pages of contour plots in R (including many hints on stackoverflow) without success. Here is my data to contour, including adding a map of Rwanda (the data consists of 14 values of longitude, latitude and rain as x,y and z): Lon Lat Rain 28.92 -2.47 83.4 29.02 -2.68 144 29.25 -1.67 134.7 29.42 -2.07 174.9 29.55 -1.58 151.5 29.57 -2.48 224.1 29.6 -1.5 254.3 29.72 -2.18 173.9 30.03 -1.95 154.8 30.05 -1.6 152.2 30.13 -1.97 126.2 30.33 -1.3 98.5 30.45 -1.81 145.5 30.5 -2.15 151.3 Here is the code I tried from stackoverflow: datr <- read.table("Apr0130precip.txt"

Why does pyplot.contour() require Z to be a 2D array?

这一生的挚爱 提交于 2019-11-26 07:43:42
问题 The matplotlib.pyplot.contour() function takes 3 input arrays X , Y and Z . The arrays X and Y specify the x- and y-coordinates of points, while Z specifies the corresponding value of the function of interest evaluated at the points. I understand that np.meshgrid() makes it easy to produce arrays which serve as arguments to contour() : X = np.arange(0,5,0.01) Y = np.arange(0,3,0.01) X_grid, Y_grid = np.meshgrid(X,Y) Z_grid = X_grid**2 + Y_grid**2 plt.contour(X_grid, Y_grid, Z_grid) # Works

Python : 2d contour plot from 3 lists : x, y and rho?

自闭症网瘾萝莉.ら 提交于 2019-11-26 04:38:14
问题 I have a simple problem in python and matplotlib. I have 3 lists : x, y and rho with rho[i] a density at the point x[i], y[i]. All values of x and y are between -1. and 1. but they are not in a specific order. How to make a contour plot (like with imshow) of the density rho (interpolated at the points x, y). Thank you very much. EDIT : I work with large arrays : x, y and rho have between 10,000 and 1,000,000 elements 回答1: You need to interpolate your rho values. There's no one way to do this,

Make contour of scatter

痞子三分冷 提交于 2019-11-25 23:47:33
问题 In python, If I have a set of data x, y, z I can make a scatter with import matplotlib.pyplot as plt plt.scatter(x,y,c=z) How I can get a plt.contourf(x,y,z) of the scatter ? 回答1: You can use tricontourf as suggested in case b. of this other answer: import matplotlib.tri as tri import matplotlib.pyplot as plt plt.tricontour(x, y, z, 15, linewidths=0.5, colors='k') plt.tricontourf(x, y, z, 15) Old reply: Use the following function to convert to the format required by contourf: from numpy