13.1 Function plots
This section introduces matplotlib and develops the techniques to create the plots in Figure 13.1.
We use the matplotlib.pyplot module, which we always
import
as plt.
13.1.1 Plotting a point
In its most basic form, the plot function takes a point’s x coordinate, y coordinate, and some keyword arguments that state how to display the point.
import matplotlib.pyplot as plt
the_plot = plt.plot(1, 0.5, color="black", marker='o')
<Figure size 432x288 with 1 Axes>
The show function displays the plot.
plt.show()
The color
keyword argument sets the color of the point, and you can use
"black"
, "blue"
, "cyan"
, "green"
,
"magenta"
, "red"
, "white"
, and "yellow"...