我试图通过修改matplotlib.patches.Wedge
属性来改变center
的位置,但它似乎没有任何影响。
例如:
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
属性。我在这里缺少什么?