- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 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.
Example
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()
Output
- Related Articles
- 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 to set the bottom margin of an element?
- How do I show the same Matplotlib figure several times in a single IPython notebook?
- How to add a second X-axis at the bottom of the first one in Matplotlib?
- How to set the bottom margin of an element with JavaScript?
- How can I get the color of the last figure in Matplotlib?
- Animate CSS margin-bottom property
- How to show (0,0) on matplotlib graph at the bottom left corner?
- How do you get the footer to stay at the bottom of a Web page in HTML?
- Usage of margin-bottom property with CSS
- How do I configure the behavior of the Qt4Agg backend in Matplotlib?
- How to put the Origin at the center of the cos curve in a figure in Python Matplotlib?
- How do I change the font size of the scale in Matplotlib plots?
- Can I extend a JavaScript error? What is the best way to do so?

Advertisements