- 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
Adjusting the spacing between the edge of the plot and the X-axis in Matplotlib
To adjust the spacing between the edge of the plot and the X-axis, we can use tight_layout() method or set the bottom padding of the current figure.
- 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.
- To display the figure, use show() method.
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-2, 2, 100) y = np.exp(x) plt.plot(x, y, c='red', lw=1) plt.show()
- Show the origin axis (x,y) in Matplotlib plot
- How to change the range of the X-axis and Y-axis in Matplotlib?
- How to plot the X-axis labels on the upper-side of the plot in R?
- Matplotlib – How to plot the FFT of signal with correct frequencies on the X-axis?
- Increase the distance between the title and the plot in Matplotlib
- Filling the region between a curve and X-axis in Python using Matplotlib
- How to customize the X-axis in Matplotlib?
- Remove the X-axis ticks while keeping the grids (Matplotlib)
- How to change the spacing between ticks in Matplotlib?
- Setting the spacing between grouped bar plots in Matplotlib
- Updating the X-axis values using Matplotlib animation
- How to plot data against specific dates on the X-axis using Matplotlib?
- Increasing the space for X-axis labels in Matplotlib
- Adjusting the heights of individual subplots in Matplotlib in Python
- How to annotate a range of the X-axis in Matplotlib?