- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Adding extra axis ticks using Matplotlib
63 Lectures 6 hours
To add extra ticks in matplotlib, we can take the following Steps −
Create x and y points using numpy.
Plot x and y points over the plot, where x ticks could be from 1 to 10 (100 data points) on the curve.
To add extra ticks, use xticks() method and increase the range of ticks to 1 to 20 from 1 to 10.
To display the figure, use the show() method.
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(1, 10, 100) y = np.sin(x) plt.plot(x, y) plt.xticks(range(1, 20)) plt.show()
- Adding extra contour lines using Matplotlib 2D contour plotting
- How to customize X-axis ticks in Matplotlib?
- Adding caption below X-axis for a scatter plot using Matplotlib
- Remove the X-axis ticks while keeping the grids (Matplotlib)
- How to turn on minor ticks only on the y-axis Matplotlib?
- How to set axis ticks in multiples of pi in Python Matplotlib?
- Adding textures to graphs using Matplotlib
- How to move labels from bottom to top without adding "ticks" in Matplotlib?
- How to remove the digits after the decimal point in axis ticks in Matplotlib?
- How to add Matplotlib Colorbar Ticks?
- Setting Y-axis in Matplotlib using Pandas
- How to change the color of the axis, ticks and labels for a plot in matplotlib?
- How do you draw R-style axis ticks that point outward from the axes in Matplotlib?
- How to remove the first and last ticks label of each Y-axis subplot in Matplotlib?
- Adjusting gridlines and ticks in Matplotlib imshow