【发布时间】:2025-11-29 23:40:01
【问题描述】:
我正在为 Windows 使用 python3.6 - 32 位。我想在绘制之前将第 0 列中的所有数据除以 3600。我该怎么做呢?请看下面的代码。 PS 代码可以正常工作,只是想从 sec 获取我的时间数据。到小时(因此是 3600 值)都在同一个程序中。
import matplotlib.pyplot as plt
import csv
x = []
y = []
with open('C:\Log_data5.dat','r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
for row in plots:
x.append(float(row[0]))
y.append(float(row[5]))
plt.plot(x,y, label='Loaded from file!')
plt.ylabel('Temperature(°C)')
plt.xlabel('Time(s)')
plt.title('Temp vs. Time')
plt.ticklabel_format(style='plain')
plt.ticklabel_format(useOffset=False)
plt.legend()
plt.show()
【问题讨论】:
-
你可以把
x.append(float(row[0]))改成x.append(float(row[0])/3600.0)
标签: python-3.x divide scalar