Open In App

Matplotlib.axis.Axis.set_visible() function 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. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack.

Matplotlib.axis.Axis.set_visible() Function

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

Syntax: Axis.set_visible(self, b) 
 

Parameters: This method accepts the following parameters. 

  • b: This parameter is the boolean value.

Return value: This method does not return any value. 

Below examples illustrate the matplotlib.axis.Axis.set_visible() function in matplotlib.axis:
 

Example 1:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import matplotlib.pyplot as plt  
from mpl_toolkits.axisartist.axislines import Subplot  
    
    
fig = plt.figure()  
       
ax = Subplot(fig, 111)  
fig.add_subplot(ax)  
    
Axis.set_visible(ax.axis["right"], False)  
Axis.set_visible(ax.axis["top"], False)
  
fig.suptitle('matplotlib.axis.Axis.set_visible() \
function Example\n', fontweight ="bold")  
    
plt.show() 


Output: 

Example 2:

Python3




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


Output: 

 



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