試圖將缺失值(無)或numpy
np.nan
添加到我的matplot圖中。一般而言,這是可能有這樣的缺失值:開始時缺少值 - matplotlib
import matplotlib.pyplot as plt
fig = plt.figure(1)
x = range(10)
y = [1, 2, None, 0, 1, 2, 3, 3, 5, 10]
ax = fig.add_subplot(111)
ax.plot(x, y, 'ro')
plt.show()
不過貌似缺失值不容易在圖形的一開始就支持。
import matplotlib.pyplot as plt
fig = plt.figure(1)
x = range(10)
y = ([None]*5)+[x for x in range(5)]
ax = fig.add_subplot(111)
ax.plot(x, y, 'ro')
plt.show()
這顯示:
但我想先從x=0
,而不是x=5
。 希望有一個簡單的方法來解決這個問題。