Python中的 Matplotlib.axis.Axis.get_visible()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
Matplotlib.axis.Axis.get_visible()函数
matplotlib 库的轴模块中的Axis.get_visible()函数用于获取可见性。
Syntax: Axis.get_visible(self)
Parameters: This method does not accepts any parameter.
Return value: This method return the visibility.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.get_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, ax = plt.subplots()
ax.plot([11, 52, 4, 7, 13, 35, 81])
ax.set_title("Visibility : " +str(Axis.get_visible(ax)))
fig.suptitle('matplotlib.axis.Axis.get_visible() \
function Example\n', fontweight ="bold")
plt.show()
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import Subplot
fig = plt.figure()
ax = Subplot(fig, 111)
fig.add_subplot(ax)
X = np.arange(-40, 40, 0.5)
Y = np.arange(-40, 40, 0.5)
U, V = np.meshgrid(X, Y)
ax.quiver(X, Y, U, V)
ax.axis["right"].set_visible(False)
ax.axis["top"].set_visible(False)
print("Visibilities of Axis")
print("Bottom :", Axis.get_visible(ax.axis["bottom"]),
"\nTop :", Axis.get_visible(ax.axis["top"]),
"\nLeft :", Axis.get_visible(ax.axis["left"]),
"\nRight :", Axis.get_visible(ax.axis["right"]))
fig.suptitle('matplotlib.axis.Axis.get_visible() \
function Example\n', fontweight ="bold")
plt.show()
输出:
示例 2:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import Subplot
fig = plt.figure()
ax = Subplot(fig, 111)
fig.add_subplot(ax)
X = np.arange(-40, 40, 0.5)
Y = np.arange(-40, 40, 0.5)
U, V = np.meshgrid(X, Y)
ax.quiver(X, Y, U, V)
ax.axis["right"].set_visible(False)
ax.axis["top"].set_visible(False)
print("Visibilities of Axis")
print("Bottom :", Axis.get_visible(ax.axis["bottom"]),
"\nTop :", Axis.get_visible(ax.axis["top"]),
"\nLeft :", Axis.get_visible(ax.axis["left"]),
"\nRight :", Axis.get_visible(ax.axis["right"]))
fig.suptitle('matplotlib.axis.Axis.get_visible() \
function Example\n', fontweight ="bold")
plt.show()
输出:
Visibilities of Axis
Bottom : True
Top : False
Left : True
Right : False