To create a 2D line plot, follow these general steps:
Call the plt.figure() to create a new figure. (optional for %matplotlib inline)
Generate a sequence of values usually using linspace().
Generate a sequence of values usually by substitute the x values into a function.
Input plt.plot(x, y, [format], **kwargs) where [format] is an (optional) format string, and **kwargs are (optional) keyword arguments specifying the line properties of the plot.
Utilize plt functions to enhance the figure with features such as a title, legend, grid lines, etc.
Input plt.show() to display the resulting figure (this step is optional in a Jupyter notebook).
import matplotlib.pyplot as plt
x = np.linspace(-2,2,200)
plt.plot(x, np.cos(x - 0), color='blue') # specify color by name
plt.plot(x, np.cos(x - 1), color='g') # short color code (rgbcmyk)
plt.plot(x, np.cos(x - 2), color='0.75') # grayscale between 0 and 1
plt.plot(x, np.cos(x - 4), color=(1.0,0.2,0.3)); # RGB tuple, values 0 to 1
Image Not ShowingPossible Reasons
The image was uploaded to a note which you don't have access to
The note which the image was originally uploaded to has been deleted
import matplotlib.pyplot as plt
plt.plot(x, np.sin(x), '-g', label='sin(x)') # solid green line
plt.plot(x, np.cos(x), ':b', label='cos(x)') # dotted blue line
plt.title("A Sin/Cos Curve", fontsize=18) # we can also specify the font size
plt.xlabel("x", fontsize=14)
plt.ylabel("sin(x)", fontsize=14)
plt.legend(fontsize=12)
plt.axis('equal');
Image Not ShowingPossible Reasons
The image was uploaded to a note which you don't have access to
The note which the image was originally uploaded to has been deleted