# How do I remove the Y-axis from a Pylab-generated picture?

MatplotlibPythonData Visualization

<p>To remove the Y-axis from a Pylab-generated picture, we can get the current axis of the plot and use the <strong>set_visible(False)</strong> method.</p><h2>Steps</h2><ul class="list"><li><p>Set the figure size and adjust the padding between and around the subplots.</p></li><li><p>Create x and y data points using numpy.</p></li><li><p>Plot the x and y data points using <strong>plot()</strong> method.</p></li><li><p>Get the current axis of the current figure.</p></li><li><p>Set the visibility to False for the Y-axis.</p></li><li><p>To display the figure, use <strong>show()</strong> method.</p></li></ul><h2>Example</h2><pre class="demo-code notranslate language-python3" data-lang="python3">import numpy as np import pylab # Set the figure size pylab.rcParams[&quot;figure.figsize&quot;] = [7.50, 3.50] pylab.rcParams[&quot;figure.autolayout&quot;] = 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()</pre><h2>Output</h2><p>It will produce the following output &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/61128/removed_Y-axis.jpg" class="fr-fic fr-dib" width="700" height="327"></p>