|
基本的な円グラフといくつかの追加機能のデモ
このデモでは、基本的な円グラフに加えて、いくつかのオプション機能を示します。
- スライスラベル
- パーセンテージの自動ラベル付け
- スライスを "explode"でオフセットする
- 影を落とす
- カスタムスタートアングル
カスタム開始角度についての注意:
デフォルトの開始角度は 0 で、正の x 軸上の "Frogs" スライスを開始します。 この例では、すべてが反時計回りに 90 度回転するように startangle = 90 を設定し、フロッグスライスは正の y 軸で開始します。
import matplotlib.pyplot as plt
# Pie chart, where the slices will be ordered and plotted counter-clockwise:
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs')
fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
plt.show()

|