0

Well, I thought this would already have an answer here, but the closes I got was this one What are the differences between add_axes and add_subplot?, which is not exactly what I'm looking for. What is the difference between figure() and add_axes(), both from pyplot?

In Matplotlib tutorial it says that figure is the whole figure and add_axes is what we call the plot. But what is the difference? I went on this because I notice we could change the graph size using both, like when we do plt.figure(figsize=(8,12)) or when we do fig.add_axes([0, 0, 2, 2]). So what am I missing regarding the concepts of these two?

Thanks in advance.

dekio
  • 810
  • 3
  • 16
  • 33

1 Answers1

1

A figure is the canvas on which the elements are drawn. So the figsize determines the total, final size of your image.

Axes, created using add_axes() or add_subplot() define a "plot region" with some axes (typically X and Y) on which points and lines can be drawn. If you only have one set of Axes on your figure, then that Axes can occupy all the space of the figure. But you have have several Axes per figure, and in that case they share the total area of the figure canvas.

You can refer to this document Anatomy of a figure for more details

Diziet Asahi
  • 38,379
  • 7
  • 60
  • 75