图表上的线中断

问题描述 投票:0回答:0

我正在尝试制作一个图表来显示每月与气候平均值的偏差。该图在情节线上显示了一些中断,我不确定为什么我已经从数据集中删除了所有 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()

输出:

Climate_Anomaly_Plot_230515

正如您在输出图像中看到的,行中有断点。我希望它是一条连续的线。

python matplotlib linegraph
© www.soinside.com 2019 - 2024. All rights reserved.