Matplotlib.axes.Axes.set_visible() in Python
Last Updated :
30 Apr, 2020
Improve
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.set_visible() function in axes module of matplotlib library is used to set the artist's visibility.
Python3
Output:
Example-2:
Python3
Output:
matplotlib.axes.Axes.set_visible() Function
Syntax: Axes.set_visible(self, b) Parameters: This method accepts only one parameters.Below examples illustrate the matplotlib.axes.Axes.set_visible() function in matplotlib.axes: Example 1:Returns: This method does not return any value.
- b: This parameter is the boolean value.
# Implementation of matplotlib function
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import Subplot
fig = plt.figure()
ax = Subplot(fig, 111)
fig.add_subplot(ax)
ax.axis["left"].set_visible(False)
ax.axis["top"].set_visible(False)
fig.suptitle('matplotlib.axes.Axes.set_visible()\
function Example\n', fontweight ="bold")
plt.show()

# Implementation of matplotlib function
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()
w.set_visible(False)
fig.suptitle('matplotlib.axes.Axes.set_visible() \
function Example\n', fontweight ="bold")
plt.show()
