简体   繁体   English

Python:Matplotlib 补丁和轮廓图

[英]Python: Matplotlib Patches and Contour Plots

Is there a way to make the filling of a circle transparent when using the PatchCollection?使用 PatchCollection 时,有没有办法使圆的填充透明? I plotted a circle, and I tried setting the facecolor to 'none', but it is covering the contour map that it is plotted on top of.我绘制了一个圆圈,并尝试将 facecolor 设置为“无”,但它覆盖了绘制在其上的等高线图。 I would like to see the outline of the circle with the contouring remaining visible behind it.我想看到圆圈的轮廓,轮廓在它后面仍然可见。

The stereonet was plotted using the mplstereonet-0.2 third-party software.立体网是使用 mplstereonet-0.2 第三方软件绘制的。 Here is the part of the script where the image is plotted:这是绘制图像的脚本部分:

hold(True)



fig, ax = plt.subplots(subplot_kw = dict(projection = 'stereonet')) # Schmidt by default

cax = ax.density_contourf(strike, dip, measurement = 'poles')

ax.pole(strike, dip, 'k^', markersize = 3)
ax.grid(True)


patches = []
circle = Circle((0, 0), 0.5, facecolor = 'none', fill = False)
patches.append(circle)
p = PatchCollection(patches)
ax.add_collection(p)

cbar = fig.colorbar(cax, cmap = cm)
cbar.set_clim(0, 25)

在此处输入图片说明

I solved the problem, but thank you to anyone that was possibly looking into this.我解决了这个问题,但感谢任何可能正在研究这个问题的人。

The solution:解决方案:

    p = PatchCollection(patches, match_original = True)

This will make it so that the contour is seen behind the shape.这将使轮廓在形状后面可见。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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