|

Python 3.11.6 (matplotlib 3.7.1) では、下記のような警告があるが、実行できる。
M:\______\ellipse_rotated.py:8: MatplotlibDeprecationWarning:
Passing the angle parameter of __init__() positionally is deprecated since
Matplotlib 3.6; the parameter will become keyword-only two minor releases later.
ells = [Ellipse((1, 1), 4, 2, a) for a in angles]
Python 3.12.0 (matplotlib 3.8.1) では、下記のようにエラーがあり、実行できない。
Traceback (most recent call last):
File "E:\______\ellipse_rotated.py", line 8, in
ells = [Ellipse((1, 1), 4, 2, a) for a in angles]
^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Ellipse.__init__() takes 4 positional arguments but 5 were given
Python 3.11.6 (matplotlib 3.7.1) 及び Python 3.12.0 (matplotlib 3.8.1) で、見直し中、リファレン(matplotlib.patches.Ellipse) によると、回転角度は、キーワード( angle )で、指定するようだ。下記の改修したコードで、正常に実行できました。
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Ellipse
delta = 45.0 # degrees
angles = np.arange(0, 360 + delta, delta)
ells = [Ellipse((1, 1), 4, 2, angle=a) for a in angles]
a = plt.subplot(111, aspect='equal')
for e in ells:
e.set_clip_box(a.bbox)
e.set_alpha(0.1)
a.add_artist(e)
plt.xlim(-2, 4)
plt.ylim(-1, 3)
plt.show()
Python 3.11.6 (matplotlib 3.7.1) 及び Python 3.12.0 (matplotlib 3.8.1) 共に、正常実行です。

|