Matplotlib sub-pads versus axes versus axis (singular / plural)

Can you clarify some of the Matplotlib terms:

  • - is the word "subheadings" (or "subheading"?) synonymous with "axis"?
  • what are the singular / plural "axes" and "axis"?
+3


source to share


2 answers


This is a really confusing question.

In English, the axis is special, and the plural is the axis. The two axes of the view form two axes.

In matplotlib, an object is matplotlib.axes._axes.Axes

often simply called "axes". This object includes xaxis and yaxis, thus the name. But speaking of this object, one could call it axes in the singular. Some of them are still called axes.

Each subtask is an object Axes

, but there are objects Axes

that are not objects AxesSubplot

.
... the axes that are created through the subtask mechanism are matplotlib.axes._subplots.AxesSubplot

. This class comes from matplotlib.axes._axes.Axes

, so this subplot is axes. However, you can also create axes using different mechanisms, for example. adding axis to the drawing fig.add_axes()

. Then it will not be subtitled, and axis matplotlib.axes._axes.Axes

.



import matplotlib.pyplot as plt

fig, ax = plt.subplots()

print(ax)         # Axes(0.125,0.11;0.775x0.77)
print(type(ax))   # <class 'matplotlib.axes._subplots.AxesSubplot'>

ax2 = fig.add_axes([0.8,0.1,0.05,0.8])

print(ax2)       # Axes(0.8,0.1;0.05x0.8)
print(type(ax2)) # <class 'matplotlib.axes._axes.Axes'>

      

There are also other axes, e.g., insertion axis mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes

. This object will also be called axes.

from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
axins = zoomed_inset_axes(ax, 0.2, loc=3) 

print(axins)       # Axes(0.125,0.11;0.775x0.77)     
print(type(axins)) # <class 'mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes'>

      

+8


source


Axes are the plural of an axis. A sub typically has an x - axis and a y-axis , which together form two subheading axes .

Speak in terms of function / class names:

Figure.add_subplot

or pyplot.subplot

return an object AxesSubplot

. This, in turn, contains the object XAxis

and YAxis

.



fig = plt.figure()
ax = fig.add_subplot(111)
x = ax.xaxis

print(type(ax))   # matplotlib.axes._subplots.AxesSubplot
print(type(x))    # matplotlib.axis.XAxis

      

XAxis

derived from the base class Axis

. AxesSubplot

is derived from SubplotBase

and Axes

.

+2


source







All Articles