【matplotlib】様々な図形

円弧、楕円など

円弧や楕円はmatplotlib.patches.Arcによりプロットできます。
サンプルコードを見てみます。

import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

fig, ax = plt.subplots()
c1 = mpatches.Arc(xy=(0.3, 0.6), width=0.5, height=0.3)
ax.add_patch(c1)

c2 = mpatches.Arc(xy=(0.8, 0.3), width=0.5, height=0.3, angle=30, theta1=10, theta2=280, linewidth=5, color="r")
ax.add_patch(c2)

plt.show()

mpatches.Arcの主な引数は

  • xy:円弧の中心座標
  • width:円弧の幅
  • height:円弧の高さ
  • angle:回転角度
  • theta1:描画開始の角度
  • theta2:描画終了の角度
タイトルとURLをコピーしました