To create a plot in matplotlib, you create a figure and one or more axes (subplots) to display the data. Here's an example of how to create a figure with one axes object:
main.py158 chars8 lines
This will create a figure with one subplot and plot the data [1, 2, 3]
on the x-axis and [4, 5, 6]
on the y-axis.
You can create multiple subplots in a figure by specifying the number of rows and columns. For example, to create a figure with two subplots that are arranged vertically, you would use:
main.py278 chars11 lines
This code will create a figure with two subplots, one above the other, and plot data on each of them.
By default, matplotlib will create a single subplot if you don't specify the number of rows and columns.
gistlibby LogSnag