首页 > 解决方案 > 如何索引和绘制两个图表

问题描述

可能是初学者的问题,但我不知道如何正确索引并在 Python 中获取每个日期的图。我有一个日期列表,对于每个日期,我想绘制 2 条具有四个值的曲线。

数据集的提取

标签: pythonplotindexingdataset

解决方案


您需要使用 myplotlib 库并更改变量的数量:

import matplotlib
from matplotlib import pyplot as p
x = [0,1,2,3]
y = [67.28,67.01,66.99,67.5]
x1= [0,1,2,3]
y1= [109,112,230,321]
p.sublot(211) # 2 - number of rows, 1 - number of columns, 1 - plot number
p.plot(x,y)
p.plot(x1,y1)
p.subplot(212)
p.plot(x,y)
p.plot(x1,y1)
p.show()

您可以在此处获取有关如何绘图的更多信息:https ://matplotlib.org/stable/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py


推荐阅读