Python中的 Matplotlib.axis.Tick.set_visible()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
Matplotlib.axis.Tick.set_visible()函数
matplotlib 库的轴模块中的Tick.set_visible()函数用于将属性从其他复制到自己。
Syntax: Tick.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.Tick.set_visible()函数:
示例 1:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Tick
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import Subplot
fig = plt.figure()
ax = Subplot(fig, 111)
fig.add_subplot(ax)
Tick.set_visible(ax.axis["right"], False)
Tick.set_visible(ax.axis["top"], False)
fig.suptitle('matplotlib.axis.Tick.set_visible() \
function Example', fontweight ="bold")
plt.show()
Python3
# Implementation of matplotlib function
from matplotlib.axis import Tick
import matplotlib.pyplot as plt
import numpy as np
X = np.arange(-4, 4, 0.5)
Y = np.arange(-4, 4, 0.5)
U, V = np.meshgrid(X**2, Y**2)
fig, ax = plt.subplots()
ax.quiver(X, Y, U, V)
w = ax.get_xaxis()
Tick.set_visible(w, False)
fig.suptitle('matplotlib.axis.Tick.set_visible() \
function Example', fontweight ="bold")
plt.show()
输出:
示例 2:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Tick
import matplotlib.pyplot as plt
import numpy as np
X = np.arange(-4, 4, 0.5)
Y = np.arange(-4, 4, 0.5)
U, V = np.meshgrid(X**2, Y**2)
fig, ax = plt.subplots()
ax.quiver(X, Y, U, V)
w = ax.get_xaxis()
Tick.set_visible(w, False)
fig.suptitle('matplotlib.axis.Tick.set_visible() \
function Example', fontweight ="bold")
plt.show()
输出: