您可以通过以下方式屏蔽NaN值:
import numpy as npimport matplotlib.pyplot as pltxs = np.arange(8)series1 = np.array([1, 3, 3, None, None, 5, 8, 9]).astype(np.double)s1mask = np.isfinite(series1)series2 = np.array([2, None, 5, None, 4, None, 3, 2]).astype(np.double)s2mask = np.isfinite(series2)plt.plot(xs[s1mask], series1[s1mask], linestyle='-', marker='o')plt.plot(xs[s2mask], series2[s2mask], linestyle='-', marker='o')plt.show()
这将导致
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)