Python中的 Matplotlib.axis.Axis.remove()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
Matplotlib.axis.Axis.remove()函数
matplotlib 库的轴模块中的Axis.remove()函数用于尽可能从图中删除艺术家。
Syntax: Axis.remove(self)
Parameters: This method does not accepts any parameter.
Return value: This method return the figure after removal of the artist.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.remove()函数:
示例 1:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
fig, axs = plt.subplots()
axs.plot([1, 2, 3])
# use of remove() method
Axis.remove(axs)
fig.suptitle('matplotlib.axis.Axis.remove() \
function Example\n', fontweight ="bold")
plt.show()
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
fig, (axs, axs2) = plt.subplots(2, 1)
gs = axs2.get_gridspec()
# use of remove() method
Axis.remove(axs)
axbig = fig.add_subplot(gs[1:, -1])
axbig.annotate("Removed one Axes",
(0.4, 0.5),
xycoords ='axes fraction',
va ='center')
fig.suptitle('matplotlib.axis.Axis.remove() \
function Example\n', fontweight ="bold")
plt.show()
输出:
示例 2:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
fig, (axs, axs2) = plt.subplots(2, 1)
gs = axs2.get_gridspec()
# use of remove() method
Axis.remove(axs)
axbig = fig.add_subplot(gs[1:, -1])
axbig.annotate("Removed one Axes",
(0.4, 0.5),
xycoords ='axes fraction',
va ='center')
fig.suptitle('matplotlib.axis.Axis.remove() \
function Example\n', fontweight ="bold")
plt.show()
输出: