Matplotlib.artist.artist.get_visible()
Python matplotlib库的artist模块中的get_visible()方法用于获取可见性。
语法:Artist.get_visible(self)
参数:该方法不接受任何参数。
Returns:该方法返回可见性。
下面的例子演示了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