Open In App

Matplotlib.axes.Axes.set_visible() in Python

Improve
Improve
Like Article
Like
Save
Share
Report

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.

matplotlib.axes.Axes.set_visible() Function

The Axes.set_visible() function in axes module of matplotlib library is used to set the artist’s visibility.

Syntax: Axes.set_visible(self, b)

Parameters: This method accepts only one parameters.

  • b: This parameter is the boolean value.

Returns: This method does not return any value.

Below examples illustrate the matplotlib.axes.Axes.set_visible() function in matplotlib.axes:

Example 1:




# 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()


Output:

Example-2:




# 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()


Output:



Last Updated : 30 Apr, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads