It doesn't matter if it's sin
or cos
, so I just want to plot the external data for the time being!
Memo
A random list of 100 values.
A
$ perl -le 'print rand (10) for 0 .. 99' > rand.txt
After executing A, execute ↓ in the same directory
python
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
f = open("rand.txt", "r")
x = []
y = []
for i, line in enumerate(f):
x.append(i)
y.append(float(line))
plt.title("data")
plt.xlabel("x")
plt.ylabel("y")
plt.plot(x,y)
plt.savefig("graph.png ")
Similarly.
python
import matplotlib
matplotlib.use('Agg')
import pandas as pd
import matplotlib.pyplot as plt
data = pd.read_csv("rand.txt", header=None)
data.columns= [ 'test' ]
data.plot()
plt.savefig("graph.png ")
Recommended Posts