python - 如何在一个图中同时绘制 3 个图?
问题描述
我想在 1 个图中绘制 3 个数据集,以便我可以比较它们。
dataset2.plot(kind='scatter',x='time',y='Temp')
dataset27.plot(kind='scatter',x='teime1',y='Temp1')
dataset28.plot(kind='scatter',x='time2',y='Temp2')
请帮忙。
解决方案
请参阅此处的文档,了解您可以设置哪些参数df.plot()
您需要创建 3 个子图并绘制到这些子图。例如,您可以这样做的一种方法:
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(12,4)) #create a figure with a 12 width, 4 length
ax1 = plt.subplot(131) #subplot with 1 row, 3 columns the 1st one
ax2 = plt.subplot(132) #subplot with 1 row, 3 columns the 2nd one
ax3 = plt.subplot(133) #subplot with 1 row, 3 columns the 3rd one
dataset2.plot(kind='scatter',x='time',y='Temp',ax=ax1)
dataset27.plot(kind='scatter',x='teime1',y='Temp1',ax=ax2)
dataset28.plot(kind='scatter',x='time2',y='Temp2',ax=ax3)
plt.show()
将它们相互绘制:
ax = plt.subplot(111) #1 subplot
dataset2.plot(kind='scatter',x='time',y='Temp',ax=ax)
dataset27.plot(kind='scatter',x='teime1',y='Temp1',ax=ax)
dataset28.plot(kind='scatter',x='time2',y='Temp2',ax=ax)
推荐阅读
- scrollview - 在 SwiftUI 中,滚动视图内部 UI 视图的阴影会被滚动视图的大小截断吗?
- php - 在 PHP 中解析 ini 文件时出现语法错误
- pandas - pandas 将一个有效信号向量化为 5 行
- javascript - 改进 js 作用域的最佳方法
- pdf - € 符号会产生较大的 PDF 文件大小 (+70kb)
- svelte - Svelte awaited block 如何修改 promise 的数组值?
- reactjs - 仅当两个依赖项都更改时才运行效果挂钩
- c# - 减少微调器项目之间的空间
- azure - 将数据工厂选定的管道从 Azure 一个订阅复制到另一个订阅
- c# - 根据当前值初始化数组