Python中的 Matplotlib.artist.Artist.get_visible()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Artist 类包含呈现为 FigureCanvas 的对象的 Abstract 基类。图中所有可见元素都是 Artist 的子类。
matplotlib.artist.Artist.get_visible() 方法
matplotlib 库的艺术家模块中的get_visible() 方法用于获取可见性。
Syntax: Artist.get_visible(self)
Parameters: This method does not accepts any parameter.
Returns: This method return the visibility.
下面的示例说明了 matplotlib 中的 matplotlib.artist.Artist.get_visible()函数:
示例 1:
# Implementation of matplotlib function
from matplotlib.artist import Artist
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import Subplot
fig, ax = plt.subplots()
ax.plot([1, 2, 34, 67, 43, 5, 8])
ax.set_title("Visibility : " +str(Artist.get_visible(ax)))
fig.suptitle('matplotlib.artist.Artist.get_visible()\
function Example', fontweight ="bold")
plt.show()
输出:
示例 2:
# Implementation of matplotlib function
from matplotlib.artist import Artist
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(-20, 20, 0.5)
Y = np.arange(-20, 20, 0.5)
U, V = np.meshgrid(X, Y)
ax.quiver(X, Y, U, V)
ax.axis["bottom"].set_visible(False)
ax.axis["top"].set_visible(False)
print("Visibilities of Axis")
print("Bottom :", Artist.get_visible(ax.axis["bottom"]),
"\nTop :", Artist.get_visible(ax.axis["top"]),
"\nLeft :", Artist.get_visible(ax.axis["left"]),
"\nRight :", Artist.get_visible(ax.axis["right"]))
fig.suptitle('matplotlib.artist.Artist.get_visible()\
function Example', fontweight ="bold")
plt.show()
输出:
Visibilities of Axis
Bottom : False
Top : False
Left : True
Right : True