A figure can have more than one subplot. Earlier, you learned that you can obtain your figure and axes objects by calling plt.subplots()
and passing in a figure size. This function can take two additional arguments:
- The number of rows
- The numbers of columns
These arguments determine how many axes objects will belong to the figure, and by extension, how many axes objects will be returned to you. In the following code, nrows
is set to 1
, and ncols
is set to 2
:
fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2)
This function returns two axes objects, which you store in a tuple.
alistairmclaren1 on March 21, 2020
Why when setting lower and upper limits for x the argument is “low=” and “high=” however for variable y only the integers 1 and 5 are used?