Pyplot Basics
pyplot contains a simpler interface for creating visualizations that allow the users to plot the data without explicitly configuring the Figure and Axes themselves. They are automatically configured to achieve the desired output. It is handy to use the alias plt
to reference the imported submodule, as follows:
import matplotlib.pyplot as plt
The following sections describe some of the common operations that are performed when using pyplot.
Creating Figures
You can use plt.figure()
to create a new Figure. This function returns a Figure instance, but it is also passed to the backend. Every Figure-related command that follows is applied to the current Figure and does not need to know the Figure instance.
By default, the Figure has a width of 6.4 inches and a height of 4.8 inches with a dpi
(dots per inch) of 100. To change the default values of the Figure, we can use the parameters figsize
and dpi
.
The following code snippet shows how we can manipulate...