- Trending Categories
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 to hide ticks label in Python but keep the ticks in place?
To hide ticks label and keep the ticks in place, we can take the following steps −
Initialize x1 and x10 variables to get the x and y points, using numpy.
Plot points x and y using the plot() method.
Using xticks method, get or set the current tick locations and labels of the X-axis. Pass no arguments to return the current values without modifying them. So, pass the range(x1, x10) to get ticks but pass an empty list to hide the labels.
To display the figure, use the show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x1 = 1 x10 = 10 x = np.linspace(1, 10, 100) y = np.log(x) plt.plot(x, y) plt.xticks(ticks=range(x1, x10), labels=[]) plt.show()
Output
- Related Articles
- How to remove the first and last ticks label of each Y-axis subplot in Matplotlib?
- How to add third level of ticks in Python Matplotlib?
- How to change the spacing between ticks in Matplotlib?
- How to get timer ticks at a given time in Python?
- How to set axis ticks in multiples of pi in Python Matplotlib?
- How to customize X-axis ticks in Matplotlib?
- How to add Matplotlib Colorbar Ticks?
- How to hide axes but keep axis-labels in 3D Plot with Matplotlib?
- How to decrease the density of x-ticks in Seaborn?
- How to set the number of ticks in plt.colorbar in Matplotlib?
- Hide axis values but keep axis tick labels in matplotlib
- How to set the ticks on a Fixed Position in Matplotlib?
- How to change the axis ticks color in base R plot?
- How Ticks Can Make You Sick
- How to change the color of the ticks in the colorbar in Matplotlib?

Advertisements