質問

デカルト プロットに重ねられた極プロットの要素の zorder を制御するのが困難です。

次の例を考えてみましょう。

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()

結果は次のとおりです。enter image description here

のように見えます matplotlib を無視した zorder 散布図の。私は赤い星が青い星の上にあると予想します。

ここで私が間違っていることを説明してもらえますか?

見つけました 一つの質問, これは私と似ていますが、代わりに目盛りとグリッドに関係しています。もしかしたら同じバグなのでしょうか?

追伸Linux x86_64 を Python 2.7.6 と matplotlib 1.3.1 で実行しています。

役に立ちましたか?

解決

問題は、マークの Z オーダーを異なる軸に設定していることです。 ax そして ax2 しかしそれ以来 ax2 z オーダーが大きくなり、その中のすべてのプロットがその上に配置されます。 ax. 。解決策の 1 つは、より高い 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()

プロット:

enter image description here

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top