我正在尝试制作一个图表来显示每月与气候平均值的偏差。该图在情节线上显示了一些中断,我不确定为什么我已经从数据集中删除了所有 NaN 值。
monthly_average 和 climate_average 是 [x, y] 值的列表
import matplotlib.pyplot as plt
import math as math
# subtract the climate monthly averages from the annual monthly averages
diff = []
for j, k in zip(monthly_average, climate_average):
if math.isnan(monthly_average) == False:
diff.append(j-k)
# plot the anomalies
plt.style.use('ggplot')
plt.figure(figsize = (20,10))
plt.plot(dates, diff, color = "crimson")
plt.show()
输出:
正如您在输出图像中看到的,行中有断点。我希望它是一条连续的线。