Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is a matplotlib axes object?

When we create a new figure:

import matplotlib.pyplot as plt

fig = plt.figure()

we can see in the console an output like:

<Figure size 432x288 with 0 Axes>

so when we use add_axes:

add_axes(rect, projection=None, polar=False, **kwargs)

are we actually defining the x,y axes that encompass the "box" that will bound the figure (the axes in a more mathematical sense) and nothing more? or in fact this line of code is creating an empty figure with the desired dimensions in which any data we add later will be fitted in? (or None of the above maybe?)

That questioning left me wondering how can I physically understand what the axes are for matplotlib.

Thanks for helping.

like image 476
Chicrala Avatar asked Sep 17 '18 14:09

Chicrala


1 Answers

From the point of view of the viewer, the axes is the box which will contain the data and which (usually) has an x-axis and y-axis.

From the programmatical point of view, the axes is an object, which stores several other objects like XAxis, YAxis and provides methods to create plots. Importantly, it has a transformation stored, which allows to draw the data points in pixel space.

like image 171
ImportanceOfBeingErnest Avatar answered Oct 06 '22 18:10

ImportanceOfBeingErnest