我正在尝试绘制一系列矩形和圆形,其中圆形位于前景中。
根据以下帖子,我必须设置 zorder 参数:我添加到图表中的补丁在 alpha=1 时不是不透明的。为什么? https://stackoverflow.com/questions/5390699/patches-i-add-to-my-graph-are-not-opaque-with-alpha-1-why
当我单独绘制所有圆圈时,这种方法效果很好,但当我尝试将一系列圆圈放入一个集合并添加该集合时,即不行。
fig,ax=plt.subplots(1)
p_fancy = FancyBboxPatch((1,1),
0.5, 0.5,
boxstyle="round,pad=0.1",
fc='beige',
ec='None', zorder=1)
ax.add_patch(p_fancy)
ax.set_xlim([0,2])
ax.set_ylim([0,2])
circ=patches.Circle ((1,1), 0.2, zorder=10)
ax.add_patch(circ)
works fine:
while
fig,ax=plt.subplots(1)
p_fancy = FancyBboxPatch((1,1),
0.5, 0.5,
boxstyle="round,pad=0.1",
fc='beige',
ec='None', zorder=1)
ax.add_patch(p_fancy)
ax.set_xlim([0.,2])
ax.set_ylim([0.,2])
circ=[]
circ.append(patches.Circle ((1,1), 0.2, zorder=10))
coll=PatchCollection(circ)
ax.add_collection(coll)
才不是:
Is there a reason, or does zorder work differently with patch collections in ways that I don't understand?