Skip to content

Instantly share code, notes, and snippets.

@Esaslow
Last active January 18, 2021 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Esaslow/9b4e1bd1f76262812247a3b79fe293f2 to your computer and use it in GitHub Desktop.
Save Esaslow/9b4e1bd1f76262812247a3b79fe293f2 to your computer and use it in GitHub Desktop.
# Import our modules that we are using
import matplotlib.pyplot as plt
import numpy as np
# Create the vectors X and Y
x = np.array(range(10))
y = x ** 2
# Create the plot
plt.plot(x,y,label='y = x**2')
plt.plot(x,(1/2)* y + 7,label='y = (1/2) * (x**2) + 7')
plt.plot(x,y + 3,label='y = x**2 + 3')
plt.plot(x,y - 5,label='y = x**2 - 5')
plt.plot(x,y - 3,label='y = x**2 - 3')
# Add a title
plt.title('My first Plot with Python')
# Add X and y Label
plt.xlabel('x axis')
plt.ylabel('y axis')
# Add a grid
plt.grid(alpha=.4,linestyle='--')
# Add a Legend
plt.legend()
# Show the plot
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment