- 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
How do I extend the margin at the bottom of a figure in Matplotlib?
To fix the extension of margin at the bottom of a figure, we can take the following steps −
Using Pandas dataframe, create a df with the keys, time and speed.
Plot df.time and df.speed using plot() method.
Tick_params() is a convenience method for changing the appearance of ticks and tick labels. rotation=90 extends the tick labels at the bottom.
To fix the bottom extension, use tight_layout() method.
import numpy as np import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame(dict(time=list(pd.date_range("2021-01-01 12:00:00", periods=10)), speed=np.linspace(1, 10, 10))) plt.plot(df.time, df.speed) plt.tick_params(rotation=90) plt.show()
- How to put the title at the bottom of a figure in Matplotlib?
- How to remove whitespaces at the bottom of a Matplotlib graph?
- How can I get the color of the last figure in Matplotlib?
- How do I show the same Matplotlib figure several times in a single IPython notebook?
- How to set the bottom margin of an element?
- How to put the Origin at the center of the cos curve in a figure in Python Matplotlib?
- How to set the margins of a Matplotlib figure?
- How to add a second X-axis at the bottom of the first one in Matplotlib?
- How to put text at the corner of an equal aspect figure in Python/Matplotlib?
- How do I configure the behavior of the Qt4Agg backend in Matplotlib?
- How to show (0,0) on matplotlib graph at the bottom left corner?
- How can I set the background color on specific areas of a Pyplot figure using Matplotlib?
- Animate CSS margin-bottom property
- Usage of margin-bottom property with CSS