-1
オブジェクトのシーケンスを表す5つの要素のリストを得ました。要素0は番号1を表し、以下同様である。そのため私は、グラフ上で適切に表現これらの番号を持ってこれをしなければならなかった:グラフの横に隙間があるのはなぜですか? (matplotlib/py)
higher_chances.insert(0, 0)
plt.xlim(1,len(higher_chances))
plt.xticks(range(1, len(higher_chances)))
だから基本的に、私はそれを無視し、その後、リストの先頭に0を挿入します。
私は今グラフの右側にギャップがあり、それを削除する方法を見つけることができません。任意の助けをいただければ幸いです
リスト:[0、47.0、46.0、45.0、45.0、43.0]
以下のすべてのコード:
# Inset 0 at first index so index 1 reflect sequence of 1 candle
higher_chances.insert(0, 0)
# Convert to actual percentages for presentation
higher_chances = [ elem*100 for elem in higher_chances]
plt.plot(higher_chances)
plt.ylim(min(higher_chances[1:]), max(higher_chances[1:]))
plt.xlim(1,len(higher_chances))
plt.xticks(range(1, len(higher_chances)))
plt.xlabel('Number of consecutive bull candles', fontsize=15)
plt.ylabel('% chance of another bull candle following', fontsize=15)
plt.show()
編集:
他のコードを変更せずにplt.axis('tight')
を追加すると、グラフは次のように変わります。
xlim/ylim
を取り出してplt.axis('tight')
を追加した場合、グラフは上のものと変わりません。