试图绘制两组数组。x 对 y 和 x1 对 y1 在同一张图上。两组的日期时间值不同,但 y 和 y1 是根据相同的 x 值绘制的,而不是写入数组中的值(两组的日期不同)。
任何帮助表示赞赏!
x = ['01/01/2019', '05/11/2019', '09/02/2019', '09/10/2020', '09/19/2019', '09/24/2019',
'10/26/2019', '03/14/2020', '03/16/2020', '03/16/2020', '05/10/2020', '07/28/2020', '09/03/2020',
'14/09/2020']
y = [0.0025, 0.00881983, 0.0025, 0.009436, 0.01069436, 0.01213136, 0.00925736, 0.01503343,
0.01803343, 0.02103343, 0.02603343, 0.01353343, 0.02703343, 0.03065149]
fig,ax = plt.subplots()
ax.plot(x, y, color="blue", marker="o")
ax.set_xlabel("Time",fontsize=14)
ax.set_ylabel("Y1",color="blue",fontsize=14)
plt.xticks(rotation=90)
x1 = ['16/11/2018', '27/12/2018', '07/01/2019', '18/03/2019', '13/05/2019', '19/09/2019',
'16/03/2020', '7/09/2020', '7/09/2020']
y1 = [10, 15, 20, 30, 32, 52, 115.27, 165.27, 160.79]
ax2=ax.twinx()
ax2.plot(x1, y1, color="green",marker="o")
ax2.set_ylabel("Y2",color="green",fontsize=14)
plt.xticks(rotation=90)
plt.show()`