In Python, can the Matplotlib Contour function return the points of a particular contour line?

I had to use contour graphs to create graphs of a set of inconveniently defined hyperbolic functions. This works, and it shows a series of them with added noise (this is a TDOA passive RF geolocation problem for those familiar with such things).

Since my python program knows (x, y) goals, I want to try all the different hyperbolas that I draw around this point and generate an error ellipse. If I can make the Matplotlib contour function return the points of each contour line as it is drawn, I can process the rest of the calculations. So...

Can the Matplotlib contour function return all values ​​(x, y) for a particular contour line, for example, with f (x, y) = 0?

+4
source share
1 answer

You can draw an outline with a specific levelas follows:

c = plt.contour(X, Y, Z, [level])

Now you can extract the contour points from the returned object c(see this answer ):

v = c.collections[0].get_paths()[0].vertices
x = v[:,0]
y = v[:,1]
+4
source

All Articles