matplotlib – extracting data from contour lines
For a given path, you can get the points like this: p = cs.collections[0].get_paths()[0] v = p.vertices x = v[:,0] y = v[:,1]
For a given path, you can get the points like this: p = cs.collections[0].get_paths()[0] v = p.vertices x = v[:,0] y = v[:,1]
An alternative to work with 2.x ă3.xă4.x is: cnts, hiers = cv2.findContours(…)[-2:] Notice: cv2.findContours has changed since OpenCV 3.x, but in OpenCV 4.0 it changes back!!! In OpenCV 3.4: findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy In OpenCV 4.0: findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy
You need to interpolate your rho values. There’s no one way to do this, and the “best” method depends entirely on the a-priori information you should be incorporating into the interpolation. Before I go into a rant on “black-box” interpolation methods, though, a radial basis function (e.g. a “thin-plate-spline” is a particular type of radial … Read more
Looking at the documentation of contour one finds that there are a couple of ways to call this function, e.g. contour(Z) or contour(X,Y,Z). So you’ll find that it does not require any X or Y values to be present at all. However in order to plot a contour, the underlying grid must be known to … Read more
Here are some different possibilites using base R graphics and ggplot. Both simple contours plots, and plots on top of maps are generated. Interpolation library(akima) fld <- with(df, interp(x = Lon, y = Lat, z = Rain)) base R plot using filled.contour filled.contour(x = fld$x, y = fld$y, z = fld$z, color.palette = colorRampPalette(c(“white”, “blue”)), … Read more
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 import linspace, meshgrid from matplotlib.mlab import griddata def … Read more