我繪製了2條線和一個圓點,X軸是日期範圍。點最重要,但它出現在圖的邊界上。我想要進一步「擴大」這個情節,以便點的位置更加明顯。 換句話說,我想擴展X軸而不將新值添加到行的Y值。但是,如果我只是將幾個日期添加到行的X值,我會得到「x和y維度必須相同」的錯誤。我試圖給Y添加一些np.NaN值,這樣尺寸是相等的,但是我得到一個「需要整數」的錯誤。 我的情節: 我的代碼:爲了可讀性而擴展繪圖而不擴大線條
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
plot_x = train_original.index.values
train_y = train_original.values
ax1.plot(plot_x, train_y, 'grey')
x = np.concatenate([np.array([train_original.index.values[-1]]), test_original.index.values])
y = np.concatenate([np.array([train_original.dropna().values[-1]]), test_original.dropna().values])
ax1.plot(x, y, color='grey')
ax1.plot(list(predicted.index.values), list(predicted.values), 'ro')
ax1.axvline(x=train_end, alpha=0.7, linestyle='--',color='blue')
plt.show()