Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Working With Multiple Subplots

Give Feedback

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:

  1. The number of rows
  2. 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?

Ranit Pradhan on April 5, 2020

File “<ipython-input-14-4e84e83ed077>”, line 19 ax2.legend(loc=(0)) ^ SyntaxError: invalid syntax

–what’s the solution?

Become a Member to join the conversation.