【发布时间】:2021-05-13 09:59:30
【问题描述】:
我在对两个折线图之间的区域进行着色时遇到问题,因为它们都有不同的日期值(x 轴)。
代码如下:
plt.figure(figsize=(30,20))
fig, ax = plt.subplots(1)
plt.plot(highs['Date'], highs['Data_Value'], label = "Record High")
plt.plot(lows['Date'], lows['Data_Value'], label = "Record Low")
plt.scatter(tmin2015['Date'].tolist(), tmin2015['Data_Value'], marker='o', c='green', label="2015 record low")
x = plt.gca().xaxis
plt.xlabel("Year", fontsize=16)
plt.ylabel("Temperature in \N{DEGREE SIGN}C", fontsize=16)
plt.title("Extreme Temperature Recorded Every Year")
for item in x.get_ticklabels():
item.set_rotation(45)
plt.legend(loc='best')
# ax.fill_between(highs['Date'],lows['Data_Value'], highs['Data_Value'])
plt.show()
【问题讨论】:
标签: python pandas matplotlib data-science