Matplotlib.artist.Artist.set_visible() in Python

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Artist class contains Abstract base class for objects that render into a FigureCanvas. All visible elements in a figure are subclasses of Artist.
matplotlib.artist.Artist.set_visible() method
The set_visible() method in artist module of matplotlib library is used to set the artist’s visibility.
Syntax: Artist.set_visible(self, b)
Parameters: This method accepts the following parameters.
- b: This parameter is the boolean value.
Returns: This method does not return any value.
Below examples illustrate the matplotlib.artist.Artist.set_visible() function in matplotlib:
Example 1:
# Implementation of matplotlib function from matplotlib.artist import Artist import matplotlib.pyplot as plt from mpl_toolkits.axisartist.axislines import Subplot fig = plt.figure() ax = Subplot(fig, 111) fig.add_subplot(ax) Artist.set_visible(ax.axis["left"], False) Artist.set_visible(ax.axis["top"], False) fig.suptitle('matplotlib.artist.Artist.set_visible()\ function Example', fontweight ="bold") plt.show() |
Output:
Example 2:
# Implementation of matplotlib function from matplotlib.artist import Artist 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() Artist.set_visible(w, False) fig.suptitle('matplotlib.artist.Artist.set_visible()\ function Example', fontweight ="bold") plt.show() |
Output:



