Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 129
Kernel: Python 3 (Anaconda)
%matplotlib inline import numpy as np import matplotlib.pyplot as plt import scipy.odr as odr import math import re fileName = "readArduino-201804241504.csv" myArray = np.genfromtxt("readArduino-201804241504.csv", delimiter=',') print(myArray) volt = myArray[:,1] current = myArray[:,0] for line in open("readArduino-201804241504.csv", 'r').readlines(): if line[0] == '#': print (line)
WARNING: Some output was deleted.
figFile = re.sub(r'csv$', "png", fileName) print ("figFile = ", figFile) fig = plt.figure() ax = fig.add_subplot(111) pl1 = ax.plot( volt, current, 'ob', label = "Data") ax.set_ylabel("Current(mA)") ax.set_xlabel("VOLTAGE (V)") ax.set_title("VOLT VS. FREQUENCY") ax.grid() VfModel = intercept + slope * freq ax.plot(freq, VfModel, 'r-', label = "Model") ax.text(freq[10],2.8,"Slope = %e"%(slope)) jnk = ax.legend() fig.savefig(figFile)
figFile = readArduino-201804241504.png
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-2-d9539e32a6e1> in <module>() 3 fig = plt.figure() 4 ax = fig.add_subplot(111) ----> 5 pl1 = ax.plot( volt, current, 'ob', label = "Data") 6 ax.set_ylabel("Current(mA)") 7 ax.set_xlabel("VOLTAGE (V)") NameError: name 'volt' is not defined
Image in a Jupyter notebook