简体   繁体   中英

Extract specific paths from matplotlib contour plot

I have the following contour plots:

fig, axes = plt.subplots(1,6, figsize=(18,3))

for idx in range(6):
    axes[idx].contour(KX[kxl:kxr,kxl:kxr],KY[kxl:kxr,kxl:kxr],eigs[kxl:kxr,kxl:kxr,idx].real, levels=[0])
    axes[idx].set_xlabel(x_label_k)

axes[0].set_ylabel(y_label_k)

6个特征值轮廓

Overlapping them results in the following image:

fig, ax = plt.subplots(1,1, figsize=(4,4))

for idx in range(6):
    ax.contour(KX[kxl:kxr,kxl:kxr],KY[kxl:kxr,kxl:kxr],eigs[kxl:kxr,kxl:kxr,idx].real, levels=[0])

ax.set_xlabel(x_label_k)
ax.set_ylabel(y_label_k)

重叠轮廓

From the above image, I am interested in plotting just the 4 "circle-like" shapes that are shown in the edited image below:

编辑的圈子

If possible, I would like the pairs of (kx, ky) points that make up these elongated circles, without any of the points from the other artifacts.

I have seen that there is a way of extracting point values from a contour plot along the lines of this question , however, that gives me a set of (2000,2000) points which I have no idea how to filter. I was thinking maybe something can be done based on paths from the contour plots?

Note that one can actually see where the circle-shapes originate in the row of 6 plots, but the problem is that in order to make up the 2 smaller inner circles one has to combine subplots 2,3,4 and 5. For the larger outer ones, it is simpler as they are relative well separated in subplots 5 and 6.

While you have set of points extracted from contours, try RANSAC . An implementation in C# to extract circles from noisy points is given here . A general and simple Python implementation is given here .

You may also try Least Square Circle Fitting for which an example in Python is given here .

Good Luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM