はじめに
matplotlibで極座標の棒グラフを表示する方法について説明する。
コード

解説
モジュールのインポートなど
バージョン
データの生成
np.linspace(0, 2*np.pi, N)で0から2πまでの等間隔なN個の配列を作成する。
thetaの値に応じて色が変わるようにcolorsを作成する。
極座標棒グラフの表示
axをplt.subplot(111, projection=’polar’)とすることで極座標グラフとなる。これにax.barで棒グラフを表示する。

radiiを変化させた場合

widthを変化させた場合

参考
Bar chart on polar axis — Matplotlib 3.2.1 documentation
matplotlib.projections — Matplotlib 3.2.1 documentation
コメント