Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Creating a Canvas | Matplotlib Introduction
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Ultimate Visualization with Python

bookCreating a Canvas

matplotlib has three layers:

  • Backend layer: renders plot to screens or files;
  • Artist layer: describes how data is arranged, is made up of one object, Artist;
  • Scripting layer: connects the previous two layers and simplifies access to them.

The main focus is on the scripting layer with the pyplot module and the artist layer. The artist layer includes the following:

  • Containers (e.g. Figure, Axes);
  • Primitives (e.g., line, rectangle, circle, text, etc).

Figure is the main Artist object and can be thought of as a canvas where all the plots will be located. Basically, it holds everything together.

On the other hand, Axes is an object made up of two axis objects, x-axis and y-axis.

Note
Note

Figure = canvas, Axes = x-axis + y-axis.

Now let's look at the creation of the Figure and its Axes:

1234
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot() plt.show()
copy
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 3

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

Can you explain the difference between Figure and Axes in more detail?

What happens if I call plt.subplots() with different arguments?

How can I add data to the plot instead of leaving it empty?

bookCreating a Canvas

Swipe to show menu

matplotlib has three layers:

  • Backend layer: renders plot to screens or files;
  • Artist layer: describes how data is arranged, is made up of one object, Artist;
  • Scripting layer: connects the previous two layers and simplifies access to them.

The main focus is on the scripting layer with the pyplot module and the artist layer. The artist layer includes the following:

  • Containers (e.g. Figure, Axes);
  • Primitives (e.g., line, rectangle, circle, text, etc).

Figure is the main Artist object and can be thought of as a canvas where all the plots will be located. Basically, it holds everything together.

On the other hand, Axes is an object made up of two axis objects, x-axis and y-axis.

Note
Note

Figure = canvas, Axes = x-axis + y-axis.

Now let's look at the creation of the Figure and its Axes:

1234
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot() plt.show()
copy
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 3
some-alt