【发布时间】:2022-01-20 16:30:33
【问题描述】:
对于 eink 显示器,它需要使用恰好 128x250 像素的 png 文件。
从一个小的温度和湿度记录器中,我得到如下结果:
Date,Time,Temperature,Humidity
12.12.2021,17:02,23.8,48.9
12.12.2021,17:03,22.8,45.1
12.12.2021,17:04,22.7,44.5
12.12.2021,17:05,22.6,44.6
12.12.2021,17:06,22.6,45.4
12.12.2021,17:07,22.5,45.1
13.12.2021,13:02,23.8,48.9
13.12.2021,13:03,22.8,45.1
13.12.2021,13:04,22.7,44.5
13.12.2021,13:05,22.6,44.6
13.12.2021,13:06,22.6,45.4
13.12.2021,13:07,22.5,45.1
14.12.2021,19:02,23.8,48.9
14.12.2021,19:03,22.8,45.1
14.12.2021,19:04,22.7,44.5
14.12.2021,19:05,22.6,44.6
14.12.2021,19:06,22.6,45.4
14.12.2021,19:07,22.5,45.1
我使用 python 做了一些简单的绘图,比如(我是 python 中的一个小人物):
from pandas import read_csv as pd
from matplotlib import pyplot as plt
Raspilog = pd('Temp.csv', header=0, squeeze=True)
Raspilog_CDate = Raspilog[Raspilog.Date == "13.12.2021"]
fig, ax = plt.subplots()
ax.plot(Raspilog_CDate.Time, Raspilog_CDate.Temperature, color="red")
ax2 = ax.twinx()
ax2.set(ylim=(0, 100))
ax2.plot(Raspilog_CDate.Time, Raspilog_CDate.Humidity, color="black")
plt.show()
结果如下:
但我需要它是 128x250 像素并保存为 png
我已经在互联网上阅读了有关 DPI 和英寸等的信息。在我看来,没有简单的解决方案:(有谁知道如何做到这一点?
【问题讨论】:
-
这并不难。
pyplot的默认 DPI 是 100,所以plt.figure(figsize=(2.5, 1.28) )应该做你想做的事。
标签: python python-3.x matplotlib