Skip to content
Related Articles

Related Articles

How to Plot Multiple Series from a Pandas DataFrame?

View Discussion
Improve Article
Save Article
  • Last Updated : 28 Nov, 2021

In this article, we will discuss how to plot multiple series from a dataframe in pandas.

Series is the range of the data  that include integer points we cab plot in pandas dataframe by using plot() function

Syntax:

matplotlib.pyplot(dataframe['column_name'])

We can place n number of series and we have to call the show() function to display the plot

Example 1: Python code to create four dataframes and plot

Python3




#import matplotlib
import matplotlib.pyplot as plt
  
# import pandas module
import pandas as pd
  
# create a dataframe with four columns
data = pd.DataFrame({'data1': [1, 2, 3, 4, 21], 
                     'data2': [6, 7, 8, 9, 10], 
                     'data3': [11, 23, 21, 45, 67],
                     'data4': [22, 33, 45, 34, 56]})
  
# plot one by one
plt.plot(data['data1'])
plt.plot(data['data2'])
plt.plot(data['data3'])
plt.plot(data['data4'])
  
# set y label
plt.ylabel('Distance')
  
# set x label
plt.xlabel('Time')
  
# set title
plt.title('Travelling')
  
# display plot
plt.show()


Output:

Example 2: Plot with two columns from the dataframe

Python3




#import matplotlib
import matplotlib.pyplot as plt
  
# import pandas module
import pandas as pd
  
# create a dataframe with two columns
data = pd.DataFrame({'data1': [1, 2, 3, 4, 21],
                     'data2': [6, 7, 8, 9, 10]})
  
# plot one by one
plt.plot(data['data1'])
plt.plot(data['data2'])
  
# set y label
plt.ylabel('Distance')
  
# set x label
plt.xlabel('Time')
  
# set title
plt.title('Travelling')
  
# display plot
plt.show()


Output:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!