- 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
Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
To plot multiple time-series data frames into a single plot using Pandas, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create a Pandas data frame with time series.
- Set the time series index for plot.
- Plot rupees and dollor on the plot.
- To display the figure, use show() method.
Example
import numpy as np import pandas as pd from matplotlib import pyplot as plt, dates plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame(dict(date=list(pd.date_range("2021-01-01", periods=10)), rupees=np.linspace(1, 10, 10), dollar=np.linspace(10, 20, 10))) df.set_index(pd.to_datetime(df.date), drop=True).plot() df = df.set_index(pd.to_datetime(df.date), drop=True) df.rupees.plot(grid=True, label="rupees", legend=True) df.dollar.plot(secondary_y=True, label="dollar", legend=True) plt.show()
Output
- Related Articles
- How to plot histograms from dataframes in Pandas using Matplotlib?
- Python - Create a Time Series Plot with multiple columns using Line Plot
- Annotate Time Series plot in Matplotlib
- Plot 95% confidence interval errorbar Python Pandas dataframes in Matplotlib
- How to plot multiple time series using ggplot2 in R?
- How to plot arbitrary markers on a Pandas data series using Matplotlib?
- How do you plot a vertical line on a time series plot in Pandas?
- Python - Create a Time Series Plot using Line Plot with Seaborn
- How to plot two Pandas time series on the same plot with legends and secondary Y-axis in Matplotlib?
- How to plot a kernel density plot of dates in Pandas using Matplotlib?
- How to plot a bar graph in Matplotlib from a Pandas series?
- Plot multiple boxplots in one graph in Pandas or Matplotlib
- How to plot multiple histograms on same plot with Seaborn using Matplotlib?
- Plot multiple columns of Pandas DataFrame using Seaborn
- Frequency plot in Python/Pandas DataFrame using Matplotlib

Advertisements