pandasで円グラフ作成
pandasでpltは直接できて便利
defaulte_fig_size = plt.rcParams["figure.figsize"] plt.rcParams["figure.figsize"] = [12.0, 10.0] # plt.figure() # fig, axes = plt.subplots(nrows=4, ncols=1, ) fig = plt.figure() ax1 = fig.add_subplot(221) ax1.title.set_text('all member') df_all_cluster[["count_cluster"]].plot(kind='pie', subplots=True, title='all member', ax=ax1, legend=False) ax2 = fig.add_subplot(222) df_2[["count_cluster"]].plot(kind='pie', subplots=True, title='ax2', ax=ax2, legend=False) ax2.title.set_text('ax2') ax3 = fig.add_subplot(223) df_3[["count_cluster"]].plot(kind='pie', subplots=True,title='ax3', ax=ax3, legend=False) ax3.title.set_text('ax3') ax4 = fig.add_subplot(224) df_4[["count_cluster"]].plot(kind='pie', subplots=True, title='ax4', ax=ax4, legend=False) ax4.title.set_text('ax4') plt.savefig('cluster.png', dpi=None) plt.show() plt.rcParams["figure.figsize"] = defaulte_fig_size plt.close('all')
以下でも良いかも。
fig, axes = plt.subplots(nrows=4, ncols=1, figsize=(12, 10)) # 左上 ax[0, 0].plot(x, y1) # 右上 ax[0, 1].plot(x, y2) # 左下 ax[1, 0].plot(x, y3) # 右下 ax[1, 1].plot(x, y4)