I have been trying to print several equations I have using numpy and matplotlib.
The functions are stored on a text file, one equation per line. These equations look like this: np.exp(6.6506+(-171.637)/(x*32))
My idea was to iterate to each line, generate the plot and save it somewhere. My code:
import numpy as np
import matplotlib.pyplot as plt
source = "path/to/list.txt"
with open(source) as f:
for line in f.readlines():
x = np.linspace(0,200)
y = line
plt.plot(x,y)
plt.savefig(str( line + ".png"))
plt.close()
I get the results I want by removing the loops part and replacing y = line
by y = np.exp(6.6506+(-171.637)/(x*32))
How can I plot all equations in my txt file? Plots are very simple and 2D.