2017-07-04 3 views
0

私はサブプロットを使ってパンダのデータフレームからプロットしています。その結果、いくつかの軸を持つnp.arrayが得られます。パンダプロットの軸出力の配列を編集する

array([<matplotlib.axes._subplots.AxesSubplot object at blablabla>, 
     <matplotlib.axes._subplots.AxesSubplot object at blablabla>, 
     <matplotlib.axes._subplots.AxesSubplot object at blablabla>]) 

この出力を取得してタイトル、xラベルを編集し、pdfとして保存したいと考えています。それが1軸だけの場合は、まずの.plotの出力を取得してから、タイトルを設定してfig = ax.get_figure()という数値を取得して、必要な方法で保存します。私はどうすれば同じことができますか?

答えて

0

軸のリストを取得するには、ax =のdf.plotのinfrontを使用しましょう。

df = pd.DataFrame(np.random.randn(1000, 4), columns=list('ABCD')) 
df = df.cumsum() 

ax = df.plot(subplots=True) 
ax[0].set_title('Series A') 
ax[1].set_title('Series B') 
ax[2].set_title('Series C') 
ax[3].set_title('Series D') 
fig = ax[0].get_figure() 
fig.tight_layout() 

enter image description here

:次に、以下のように...など、オブジェクトとset_title各軸にアクセスするには、リストのスライスを使用することができます
関連する問題