python - 使用 matplotlib 和 numpy 在图中获得“更宽”的分辨率?
问题描述
我昨天刚开始使用 python,因为它似乎是我们任务的一个很好且简单的解决方案。我们正在制作一个记录器,它将监控该领域的电池充电器和其他设备的长期测试。
现在我正在使用由数字生成器制作的模拟数字,我们很快就会有一些实际的和更偶数的数字可以使用,但实际的掌握让我担心,因为它是如此压缩。有没有办法“加宽”x轴,提高分辨率,从而拉伸图形?
import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('test.txt')
x = data[:, 0]
y = data[:, 1]
y2 = data[:, 2]
y3 = data[:, 3]
fig = plt.figure(facecolor = ("Pink"))
ax = fig.add_subplot(111)
ax.plot(x, y, '--', label='Voltage')
ax.plot(x, y2, '-.', label='Current')
ax2 = ax.twinx()
ax2.plot(x, y3,'g:', label='Temperature')
fig.legend(edgecolor = ("DarkBlue"), facecolor = ("LightBlue"), loc="upper right", bbox_to_anchor=(1,1), bbox_transform=ax.transAxes)
ax.set_title("Test Surveillance", color = ("Purple"))
ax.set_xlabel('Milliseconds', color = ("LightGreen"))
ax.set_ylabel('Volts and Amps', color = ("DarkGrey"))
ax2.set_ylabel('Celsius', color = ("LightBlue"))
plt.show()
忽略配色方案,这是为了测试和惹恼我的朋友。
解决方案
推荐阅读
- sql - 如何添加分号;使用 jOOQ 自动生成每个生成的 sql 语句
- java - 当背景色调属性在按钮中为默认值时,如何更改android中单击按钮的背景颜色?
- html - 当缩放时包装器缩小到一定宽度时,如何让 flexbox-div 中的元素折叠起来?
- swift - Firebase 连接被终止
- pi - 树莓派 GPIO 键盘/鼠标输入
- python - 为什么 PyAudio 会从 NumPy 数组中截断音频?
- amazon-web-services - AWS SAM/CloudFormation 模板 Lambda 删除保护
- javascript - TypeScript:定义一个指定新功能的类型
- mysql - 为什么 MySQL COUNT 函数有时会进行全表扫描,而有时会使用索引?又该如何避免呢?
- reactjs - 使用 Openlayers 处理 Extent Interaction 事件