-
Notifications
You must be signed in to change notification settings - Fork 0
Lab 2: Plotting and Visualization
ChrisPerez13 edited this page Feb 1, 2024
·
3 revisions
The goal of this lab was to learn how to plot complex functions and how to visualize them since we will be doing this throughout the semester. We downloaded data sets and modified them into arrays to be plotted showing their relationships. We downloaded images and created lines of best fit for a data set. Used standard deviation and mean lines on a histogram to show values.
Use the !wget to download data sets and use np.loadtxt to read the data
!wget
star_data = np.loadtxt('stars.txt')
theta = np.linspace(0,2*np.pi,200)
r = np.sin(theta)
!wget
myimage = image.imread("_____")
plt.imshow(myimage)
c = np.polyfit(x,y,1)
xline = np.linspace(xmin,xmax,100)
yline = np.polyval(c,xline)
gauss_values = np.random.normal(size=100)
plt.hist(gauss_values)
print("average value = {:.2f}".format(np.mean(gauss_values)))
print("the STD = {:.2f}".format(np.std(gauss_values)))
plt.axvline(np.mean(gauss_values),color='red')
plt.axvline(np.std(gauss_values),color='blue',linestyle='--')
plt.axvline(-np.std(gauss_values),color='cyan',linestyle='--')