Matplotlib是Python中的一個庫,它是數字的-NumPy庫的數學擴展。軸類包含大多數圖形元素:Axis,Tick,Line2D,Text,Polygon等,並設置坐標係。 Axes實例通過callbacks屬性支持回調。
matplotlib.axes.SubplotBase()類
它是子圖(即Axes實例)的基類。它提供了各種新方法,這些方法用於生成和操縱圖形對象內的一組軸。
注意:在SubplotBase中,Base是對象。
用法: class matplotlib.axes.SubplotBase(fig, *args, **kwargs)
參數:這接受以下描述的以下參數:
- fig:此參數是matplotlib.figure.Figure。
- *args:此參數包含值的元組(nrows,ncols,index),換句話說,它是圖中具有維度(nrows,ncols)的子圖的數組,而index是要創建的子圖的索引。
以下示例說明了matplotlib.axes中的matplotlib.axes.SubplotBase()類:
範例1:
# 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()
輸出:
範例2:
# 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()
輸出:
相關用法
注:本文由純淨天空篩選整理自SHUBHAMSINGH10大神的英文原創作品 Matplotlib.axes.SubplotBase() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。