Python中的 Matplotlib.axis.Axis.set_visible()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
Matplotlib.axis.Axis.set_visible()函数
matplotlib 库的轴模块中的Axis.set_visible()函数用于设置艺术家的可见性。
Syntax: Axis.set_visible(self, b)
Parameters: This method accepts the following parameters.
- b: This parameter is the boolean value.
Return value: This method does not return any value.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.set_visible()函数:
示例 1:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import Subplot
fig = plt.figure()
ax = Subplot(fig, 111)
fig.add_subplot(ax)
Axis.set_visible(ax.axis["right"], False)
Axis.set_visible(ax.axis["top"], False)
fig.suptitle('matplotlib.axis.Axis.set_visible() \
function Example\n', fontweight ="bold")
plt.show()
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
import numpy as np
X = np.arange(-20, 20, 0.5)
Y = np.arange(-20, 20, 0.5)
U, V = np.meshgrid(X, Y)
fig, ax = plt.subplots()
ax.quiver(X, Y, U, V)
w = ax.get_xaxis()
Axis.set_visible(w, False)
fig.suptitle('matplotlib.axis.Axis.set_visible() \
function Example\n', fontweight ="bold")
plt.show()
输出:
示例 2:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
import numpy as np
X = np.arange(-20, 20, 0.5)
Y = np.arange(-20, 20, 0.5)
U, V = np.meshgrid(X, Y)
fig, ax = plt.subplots()
ax.quiver(X, Y, U, V)
w = ax.get_xaxis()
Axis.set_visible(w, False)
fig.suptitle('matplotlib.axis.Axis.set_visible() \
function Example\n', fontweight ="bold")
plt.show()
输出: