アメグラ2号のブログ

1980年代後半の古き良きビデオゲームのほか、オッサンの個人的備忘録

python CSVデータをグラフにしてみる

f:id:game-allergy:20210611094841p:plain

デジタル温度ロガーのCSVデータをグラフにしてみる。

csvを取り込んで、Dataframe,matplotlibでグラフを出力。

経緯はこちら

game-allergy.hatenablog.com

スクリプトは以下

import pandas as pd
import matplotlib.pyplot as plt
import japanize_matplotlib

filename='export.csv'

df = pd.read_csv(filename)

pd.set_option('display.max_rows', None)
print(df)

fig, ax = plt.subplots(figsize=(8, 4))
ax.plot(df["Time"], df["CH1"])
ax.plot(df["Time"], df["CH2"])

labels = ax.get_xticklabels()
plt.setp(labels, rotation=90, fontsize=10)

ax.grid()

plt.show()