1
私のグラフをy軸の全範囲(10)から表示しようとしていますが、yの最小値は4、最高は7です。範囲内のすべての点についてy軸を表示するにはどうしたらいいですか?値がある場所は?matplotlib.pyplotがデータの存在するグラフのセクションのみを表示しないようにするにはどうすればよいですか?
私のスクリプトは次のとおりです。エラーが発生
plt.set_autocale_on(False)
:
"'module' object has no attribute 'set_autocale_on'"
私は私にはない発見した他のもの、私が使用しようとしました
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import datetime as dt
#X axis data
dates = ['03/04/2017', '04/04/2017', '05/04/2017', '06/04/2017', '07/04/2017', '08/04/2017', '09/04/2017',
'10/04/2017', '11/04/2017', '12/04/2017', '13/04/2017', '14/04/2017', '15/04/2017', '16/04/2017']
#Y axis data
occurence_number = [7,5,4,6,7,6,6,4,5,7,7,6,7,7]
#formatting the date information
x = [dt.datetime.strptime(d, '%d/%m/%Y').date() for d in dates]
y = occurence_number
#labeling the x and y axis
plt.xlabel('Date')
plt.ylabel('Instances of Behavior')
#here I tried to set the yticks in an attempt to show them all
plt.yticks(range(10))
#formating y axis values for matplotlib
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%d/%m/%Y'))
plt.gca().xaxis.set_major_locator(mdates.DayLocator())
plt.plot(x,y)
plt.gcf().autofmt_xdate()
plt.show()
実装方法を理解する。グラフには現在正しい値が表示されていますが、値がない場合は0 - > 4および7 - > 10のyラベルが表示されるように「ズーム」したいと思います。
'plt.gca()。set_ylim(0、10)'や 'plt.ylim(0、10)' – Paul
これは素晴らしい作品! –