excaza - 10 months ago 69

Python Question

I am attempting to shift the position of a

`matplotlib.patches.Wedge`

`center`

For example:

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

Produces the following:

Which is clearly incorrect.

A similar approach functions fine for

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

And

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

I thought it might be

`Wedge`

`xy`

`center`

`Wedge`

`xy`

Answer Source