我试图通过修改其 center 属性来移动 matplotlib.patches.Wedge 的位置,但它似乎没有任何效果。
例如:
import matplotlib.pyplot as plt
import matplotlib.patches as patches
fig = plt.figure()
ax = fig.add_subplot(111)
tmp = patches.Wedge([2, 2], 3, 0, 180)
ax.add_artist(tmp)
tmp.center = [4, 4] # Try to move!
ax.set_xlim([0, 10])
ax.set_ylim([0, 10])
print(tmp.center)
plt.show()
产生以下内容:
这显然是不正确的。
类似的方法适用于 matplotlib.patches.Ellipse:
import matplotlib.pyplot as plt
import matplotlib.patches as patches
fig = plt.figure()
ax = fig.add_subplot(111)
tmp = patches.Ellipse([2, 2], 2, 2)
ax.add_artist(tmp)
tmp.center = [4, 4] # Try to move!
ax.set_xlim([0, 10])
ax.set_ylim([0, 10])
print(tmp.center)
plt.show()
和 matplotlib.patches.Rectangle(从 center 到 xy)
import matplotlib.pyplot as plt
import matplotlib.patches as patches
fig = plt.figure()
ax = fig.add_subplot(111)
tmp = patches.Rectangle([2, 2], 3, 2)
ax.add_artist(tmp)
tmp.xy = [4, 4] # Try to move!
ax.set_xlim([0, 10])
ax.set_ylim([0, 10])
print(tmp.xy)
plt.show()
我认为它可能是 Wedge 利用 xy 而不是 center,但是 Wedge 对象没有xy 属性。我在这里缺少什么?
请您参考如下方法:
