- 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 append a single labeled tick to X-axis using matplotlib?
Tp append a single labeled tick to X-axis using matplotlib, we can take the following steps.
Steps
Set the figure size and adjust the padding between and around the subplots.
Create x and y data points using numpy.
Plot x and y data points using plot() method.
Set xticks at a single point.
Set the tick label for single tick point.
To display the figure, use Show() method.
Example
import numpy as np import matplotlib.pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create x and y data points x = np.linspace(-5, 5, 50) y = np.sin(x) # Plot x and y data points fig, ax = plt.subplots(1, 1) p = ax.plot(x, y) # Set xticks at a point ax.set_xticks([-1.075]) # Set xticklabels for the point ax.set_xticklabels(["$\bf{It\ is -\!1.075\ label}$"]) # Display the plot plt.show()
Output
It will produce the following output −
- Related Articles
- Changing the color of a single X-axis tick label in Matplotlib
- Overlapping Y-axis tick label and X-axis tick label in Matplotlib
- How to adjust 'tick frequency' in Matplotlib for string X-axis?
- How to add footnote under the X-axis using Matplotlib?
- Aligning table to X-axis using matplotlib Python
- How to turn off the upper/right axis tick marks in Matplotlib?
- How to add a second X-axis in Matplotlib?
- How to rotate X-axis tick labels in Pandas bar plot?
- How to change the separation between tick labels and axis labels in Matplotlib?
- How to adjust 'tick frequency' in Matplotlib for string Y-axis?
- Hide axis values but keep axis tick labels in matplotlib
- How to customize the X-axis in Matplotlib?
- How to customize X-axis ticks in Matplotlib?
- How to show all the X-axis tick values in Python Plotly?
- How do I change the axis tick font in a Matplotlib plot when rendering using LaTeX?

Advertisements