Sie sind auf Seite 1von 3

Michael Jonathan

Dr. Hugh Williams


PHYS 414-401
23 January 2019
Basic Function Plot
Plot 1
# Load the numpy library
import numpy as np

#Load the math library


import math

# Load the the pyplot library giving it the nickname "plt" for short
import matplotlib.pyplot as plt

# Create an array of 100 linearly-spaced points from 0 to 9


x = np.linspace(0,math.pi,100)
print ("x=",x)

# Calculation the sin of the numbers in the array


y = np.sin(x)
print ("y=",y)

# Create the "plot" in memory (doesn't draw it yet)


plt.plot(x,y)

# Adding Labels
plt.title('Michael Jonathan')
plt.xlabel('Angle [radians]')
plt.ylabel('Magnitude of Displacement [mm]')

# Save the plot in a file


# I have no idea why, but this needs to be before the "show" command?!
plt.savefig('basicfunctionplot.png')

# Draw the plot to the screen


plt.show()
Plot 2
# Load the numpy library
import numpy as np

# Load the the pyplot library giving it the nickname "plt" for short
import matplotlib.pyplot as plt

# Create an array of 100 linearly-spaced points from 0 to 9


x = np.linspace(0,0.99,100)
print ("x=",x)

# Calculation the sin of the numbers in the array


y = 9.10938356*(10**(-31))*((1-(x**2))**(-0.5))
print ("y=",y)

# Create the "plot" in memory (doesn't draw it yet)


plt.plot(x,y)

# Adding Labels
plt.title('Velocity Dependence of the Electron Mass')
plt.xlabel('Velocity as a Fraction of the Speed of Light')
plt.ylabel('Relativistic Electron Mass [kg]')

# Save the plot in a file


# I have no idea why, but this needs to be before the "show" command?!
plt.savefig('velocity_dependence_electron_mass.png')

# Draw the plot to the screen


plt.show()

Das könnte Ihnen auch gefallen