Matplotlib.axes.SubplotBase() in Python
Last Updated :
21 Apr, 2020
Improve
Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
It is a base class for subplots which is Axes instances. It provide various new methods which are used to generate and manipulate a set of Axes within a figure object.
Note: In the SubplotBase, the Base is the object.
Python3 1==
Output:
Example 2:
Python3 1==
Output:
matplotlib.axes.SubplotBase() class
Syntax: class matplotlib.axes.SubplotBase(fig, *args, **kwargs) Parameters: This accept the following parameters that are described below:Below examples illustrate the matplotlib.axes.SubplotBase() class in matplotlib.axes: Example 1:
- fig: This parameter is the matplotlib.figure.Figure.
- *args: This parameter contains the tuple of values (nrows, ncols, index).In other words, it is the array of subplots in the figure has dimensions (nrows, ncols) and index is the index of the subplot being created.
# Implementation of matplotlib function
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import SubplotZero
import numpy as np
fig = plt.figure(figsize =(4, 3))
# Zero is the base
ax = SubplotZero(fig, 1, 1, 1)
fig.add_subplot(ax)
xx = np.arange(0, 2 * np.pi, 0.01)
ax.plot(xx, np.sin(xx))
fig.suptitle('matplotlib.axes.SubplotBase() class Example\n\n',
fontweight ="bold")
plt.show()

# Implementation of matplotlib function
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import Subplot
fig = plt.figure()
ax = Subplot(fig, 111)
fig.add_subplot(ax)
ax.axis["left"].set_visible(False)
ax.axis["top"].set_visible(False)
fig.suptitle('matplotlib.axes.SubplotBase() class Example\n\n',
fontweight ="bold")
plt.show()
