【发布时间】:2022-06-15 04:31:41
【问题描述】:
导入 notebook_defect 文件后,我绘制了 3 个图表,分别表示 1) 随时间变化的缺陷 2) 随时间变化的机会 3) 随时间变化的平均率和限制的缺陷率。 我想知道如何将所有 3 个图表组合成一个图形?
这是我目前所拥有的:
import pandas as pd
laptop_defects = pd.read_excel('/content/Data_Analysis_Project.xlsx')
laptop_defects
import matplotlib.pyplot as plt
plt.plot(laptop_defects.Defects)
plt.plot(laptop_defects.Opportunities)
计算缺陷率
laptop_defects['Defect Rate'] = round(laptop_defects['Defects']/ laptop_defects['Opportunities'] * 1000000,0)
laptop_defects.head()
plt.plot(laptop_defects ['Month ID(YYYYMM)'], laptop_defects['Defect Rate']);
plt.plot(laptop_defects ['Month ID(YYYYMM)'], laptop_defects['Mean Rate']);
plt.plot(laptop_defects ['Month ID(YYYYMM)'], laptop_defects['2 Sigma limit']);
plt.plot(laptop_defects ['Month ID(YYYYMM)'], laptop_defects['3 Sigma limit']);
【问题讨论】:
-
您可以试试这个:
fig, [ax1, ax2, ax3] = plt.subplots(nrows=3, ncols=1),然后将每个绘图命令提供给相应的轴。 -
Pandas 用户指南Chart Visualization 部分的哪一部分您不明白?我想也许第二个例子显示了你想要的。
标签: python matplotlib