に線グラフと棒グラフをプロットしていましたがmatplotlib
、どちらも個別にスクリプトで正常に機能していました。
しかし、私は問題に直面しています:
1.同じ出力ウィンドウに両方のグラフをプロットしたい
場合2.表示ウィンドウを1024*700にカスタマイズしたい場合
最初のケースでは、サブプロットを使用して同じウィンドウに2つのグラフをプロットしていましたが、両方のグラフに個別のx軸とy軸の名前、および個別のタイトルを付けることができません。私の失敗したコードは次のとおりです。
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
xs,ys = np.loadtxt("c:/users/name/desktop/new folder/x/counter.cnt",delimiter = ',').T
fig = plt.figure()
lineGraph = fig.add_subplot(211)
barChart = fig.add_subplot(212)
plt.title('DISTRIBUTION of NUMBER')
lineGraph = lineGraph.plot(xs,ys,'-') #generate line graph
barChart = barChart.bar(xs,ys,width=1.0,facecolor='g') #generate bar plot
plt.grid(True)
plt.axis([0,350,0,25]) #controlls axis for charts x first and then y axis.
plt.savefig('new.png',dpi=400)
plt.show()
しかし、これでは両方のグラフを正しくマークすることができません。
また、ウィンドウのサイズを1024*700に変更する方法についてのアイデアを見つけてください。