- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Plotting multiple dataframes using Pandas functionality
To plot multiple dataframes using Pandas functionality, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create two Pandas dataframes, df1 and df2, of two-dimensional, size-mutable, potentially heterogeneous tabular data.
- Plot df1 and df2 using plot() method.
- To display the figure, use show() method.
Example
import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True df1 = pd.DataFrame( dict( name=['John', 'James', 'Stephen', 'Kandy'], age=[23, 45, 12, 34] ) ) df2 = pd.DataFrame( dict( subject=['Math', 'Physics', 'Chemistry', 'Biology'], marks=[67, 98, 90, 75] ) ) ax = df1.plot(x='name', y='age') df2.plot(ax=ax, x='subject', y='marks') plt.show()
Output
It will produce the following output
- Related Articles
- Plotting Pandas DataFrames in Pie Charts using Matplotlib
- Plotting multiple line graphs using Pandas and Matplotlib
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- Merge, Join and Concatenate DataFrames using Pandas
- How to plot histograms from dataframes in Pandas using Matplotlib?
- Python - Concatenate Pandas DataFrames Without Duplicates
- How to combine dataframes in Pandas?
- How are dataframes in Pandas merged?
- Python – Get the Columns Shared by Two Pandas DataFrames using Numpy
- How to append two DataFrames in Pandas?
- Plotting a horizontal line on multiple subplots in Python using pyplot
- Python Pandas – Find the Difference between two Dataframes
- Plotting histograms against classes in Pandas / Matplotlib
- Python Pandas – Check if two Dataframes are exactly same
- Python Pandas - Finding the uncommon rows between two DataFrames

Advertisements