- 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 can I move a tick label without moving corresponding tick in Matplotlib?
To move a tick label without moving corresponding tick in Matplotlib, we can use axvline() method and can annotate it accordingly.
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Initialize a variable, delta.
- Create x and y data points using numpy.
- Plot delta using axvline() method
- Annotate that line using annotate() method.
- Plot x and y data points using plot() method.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True delta = 2.0 x = np.linspace(-10, 10, 100) y = np.sinc(x - delta) plt.axvline(delta, ls="--", color="r") plt.annotate(r"$\delta$", xy=(delta + 0.2, -0.2), color="r", size=15) plt.plot(x, y) plt.show()
Output
- Related Articles
- Overlapping Y-axis tick label and X-axis tick label in Matplotlib
- Matplotlib log scale tick label number formatting
- How to change the datetime tick label frequency for Matplotlib plots?
- Changing the color of a single X-axis tick label in Matplotlib
- Centering x-tick labels between tick marks in Matplotlib
- Hiding major tick labels while showing minor tick labels in Matplotlib
- How to rotate tick labels in a subplot in Matplotlib?
- How to remove a frame without removing the axes tick labels from a Matplotlib figure in Python?
- How to make longer subplot tick marks in Matplotlib?
- How do I change the axis tick font in a Matplotlib plot when rendering using LaTeX?
- How do I convert (or scale) axis values and redefine the tick frequency in Matplotlib?
- How to show tick labels on top of a matplotlib plot?
- Getting empty tick labels before showing a plot in Matplotlib
- Change grid interval and specify tick labels in Matplotlib
- Show tick labels when sharing an axis in Matplotlib

Advertisements