- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I remove the Y-axis from a Pylab-generated picture?
To remove the Y-axis from a Pylab-generated picture, we can get the current axis of the plot and use the set_visible(False) method.
Steps
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points using numpy.
Plot the x and y data points using plot() method.
Get the current axis of the current figure.
Set the visibility to False for the Y-axis.
To display the figure, use show() method.
Example
import numpy as np import pylab # Set the figure size pylab.rcParams["figure.figsize"] = [7.50, 3.50] pylab.rcParams["figure.autolayout"] = True # Random data points x = np.random.rand(10) y = np.random.rand(10) # Plot the data points pylab.plot(x, y) # Get the current axis ax = pylab.gca() # Set Y-axis visibility to False ax.yaxis.set_visible(False) # Display the plot pylab.show()
Output
It will produce the following output −
Advertisements