Can you please clarify some Matplotlib terminology:
Axis is the axis of the plot, the thing that gets ticks and tick labels. The axes is the area your plot appears in.
Axes, when pronounced with a long e, is the plural form of the word axis, meaning imaginary lines that run through the middles of things.
Plot − Plot helps to plot just one diagram with (x, y) coordinates. Axes − Axes help to plot one or more diagrams in the same window and sets the location of the figure.
"Subplots mean a group of smaller axes (where each axis is a plot) that can exist together within a single figure. Think of a figure as a canvas that holds multiple plots." An axis means, for example, the x axis.
This is indeed a confusing matter.
In English language the singular is axis and the plural is axes. Two of the kind axis form two axes.
In matplotlib, a matplotlib.axes._axes.Axes
object is often simply called "axes". This object incorporates an xaxis and a yaxis, thus the name. But speaking of that object, one would call it axes in singular. Several of those are still called axes.
Every subplot is an Axes
object, but there are Axes
objects, which are no AxesSubplot
object. E.g. an axes, which is created through the subplot mechanism is a matplotlib.axes._subplots.AxesSubplot
. This class derives from matplotlib.axes._axes.Axes
, thus this subplot is an axes. You can however also create axes via different mechanisms, e.g. by adding an axes to the figure, fig.add_axes()
. This would then not be a subplot, but an axes, 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, like e.g. inset axes,
mpl_toolkits.axes_grid1.parasite_axes.AxesHostAxes
. This object would 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'>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With