Python 2.7 叠加在笛卡尔图上的极坐标图中元素的matplotlib zorder

Python 2.7 叠加在笛卡尔图上的极坐标图中元素的matplotlib zorder,python-2.7,matplotlib,z-order,polar-coordinates,cartesian-coordinates,Python 2.7,Matplotlib,Z Order,Polar Coordinates,Cartesian Coordinates,我很难控制叠加在笛卡尔图上的极坐标图元素的顺序 考虑这个例子: import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) ax.scatter(1, 1, marker='*', s=2000, c='r', zorder=2) ax2 = fig.add_axes(ax.get_position(), frameon=False, polar=True) ax2.scatter(1., 0.1,

我很难控制叠加在笛卡尔图上的极坐标图元素的顺序

考虑这个例子:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(1, 1, marker='*', s=2000, c='r', zorder=2)
ax2 = fig.add_axes(ax.get_position(), frameon=False, polar=True)
ax2.scatter(1., 0.1, marker='*', s=1000, c='b', zorder=1)
plt.xlim(0, 2)
plt.ylim(0, 2)
plt.show()
结果是:

它看起来像是
matplotlib
忽略了散点图的
zorder
。我希望红色的星星在蓝色的上面

你能解释一下我做错了什么吗

我发现,这有点类似于我的,但关注的是滴答线和网格。也许是同一只虫子


另外,我正在使用Python 2.7.6和matplotlib 1.3.1运行Linux x86_64。

问题是,您正在设置不同轴上标记的z顺序
ax
ax2
,但由于
ax2
具有更大的z顺序,因此它中的所有绘图都将位于
ax
之上。一种解决方案是将更高的z顺序设置为
ax
,但随后需要使背景透明或设置
frameon=False
(这可能不适合您的情况),这就是我所说的示例:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

ax.scatter(1, 1, marker='*', s=2000, c='r', zorder=2)

ax2 = fig.add_axes(ax.get_position(), frameon=False, polar=True)
ax2.scatter(1., 0.1, marker='*', s=1000, c='b', zorder=1)

ax.set_zorder(3)
ax.patch.set_facecolor('none')
#ax.patch.set_visible(False)

plt.xlim(0, 2)
plt.ylim(0, 2)
plt.show()
绘图:


是的,这正是我所怀疑的。不幸的是,我找不到关于如何在matplotlib中处理zorder的好文档。例如,有没有交叉轴zorder这样的东西?问题是我的ax的背景确实是不透明的。我想我可以在ax2上绘制红星,但坐标变得极坐标,定位和缩放变得很困难。