我有两个价格不同的列表。第一个清单是2008年至2018年,第二个清单是2010年至2018年。如何在条件下将它们绘制出来,使得2008年至2018年的年份在X轴上,而第二个列表从2010年开始?
以下是一个简短代码的示例:
from matplotlib import pyplot as plt
Geb_b30 = [11, 10, 12, 14, 16, 19, 17, 14, 18, 17]
Geb_a30 = [12, 10, 13, 14, 12, 13, 18, 16]
fig, ax = plt.subplots()
ax.plot(Geb_b30, label='Prices 2008-2018', color='blue')
ax.plot(Geb_a30, label='Prices 2010-2018', color = 'red')
legend = ax.legend(loc='center right', fontsize='x-large')
plt.xlabel('years')
plt.ylabel('prices')
plt.title('Comparison of the different prices')
plt.show()