#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 21 12:21:29 2023 @author: richardson """ import numpy as np # numpy is a numerical package import matplotlib.pyplot as plt # matplotlib is a plotting package, and # pyplot is one of the subpackages x = np.linspace(-np.pi,np.pi,100) # this makes a list (actually np array) # of the numbers between -pi and pi --- 100 of them # print(x) a = plt.plot(x,20*np.cos(x),color='red') xx = np.random.randn(20) # randn(N) chooses N random numbers # according to the normal distribution # it makes a list (actually an np array) yy = xx**2-xx-10+np.random.rand(20)*40 # xx**2 means the np array where each element # of xx is squared. # Except for the random part, it is evaluating # y = x**2 - x-10 --- just for those 20 points # rand(N) is N random numbers between 0 and 1 # (according to a uniform distribution) # 40*rand(N) means N random numbers between 0 and 40. b =plt.scatter(xx,yy,color="blue",marker="v") # choose markers here: # https://matplotlib.org/stable/api/markers_api.html#module-matplotlib.markers # this will make a scatter plot z=np.zeros(100) # vector of 100 zeros (i.e. np array of zeros) plt.plot(x,z,color="black") plt.show()