
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python - Create a Time Series Plot with multiple columns using Line Plot
To create a Time Series Plot with multiple columns using Line Plot, use the lineplot(). At first, import the required libraries −
import seaborn as sb import pandas as pd import matplotlib.pyplot as plt
Create a DataFrame. We have multiple columns in our DataFrame −
dataFrame = pd.DataFrame({'Date_of_Purchase': ['2018-07-25', '2018-10-25', '2019-01-25', '2019-05-25', '2019-08-25','2020-09-25','2021-03-25'],'Units Sold': [98, 77, 51, 70, 70, 87, 76],'Units Returned' : [60, 50, 40, 57, 62, 51, 60] })
Plot time series plot for multiple columns −
sb.lineplot(x="Date_of_Purchase", y="Units Sold", data=dataFrame) sb.lineplot(x="Date_of_Purchase", y="Units Returned", data=dataFrame)
Example
Following is the code −
import seaborn as sb import pandas as pd import matplotlib.pyplot as plt # creating DataFrame dataFrame = pd.DataFrame({'Date_of_Purchase': ['2018-07-25', '2018-10-25', '2019-01-25', '2019-05-25', '2019-08-25','2020-09-25','2021-03-25'],'Units Sold': [98, 77, 51, 70, 70, 87, 76],'Units Returned' : [60, 50, 40, 57, 62, 51, 60] }) # time series plot for multiple columns sb.lineplot(x="Date_of_Purchase", y="Units Sold", data=dataFrame) sb.lineplot(x="Date_of_Purchase", y="Units Returned", data=dataFrame) # set label plt.ylabel("Units Returned Unites Sold") plt.show()
Output
This will produce the following output −
- Related Articles
- Python - Create a Time Series Plot using Line Plot with Seaborn
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- How to plot multiple time series using ggplot2 in R?
- How do you plot a vertical line on a time series plot in Pandas?
- How to create a vertical line in a time series plot in base R?\n
- How to plot a time series in Python?
- Python Pandas - Plot multiple data columns in a DataFrame?
- Plot multiple columns of Pandas DataFrame using Seaborn
- How to create a time series plot in R without time vector?
- Annotate Time Series plot in Matplotlib
- How to plot a time series graph using Seaborn or Plotly?
- How to plot a time series array, with confidence intervals displayed in Python? (Matplotlib)
- How to create a plot in R with a different plot window size using plot function?
- How to create a plot in R with gridlines using plot function?
- How to plot multiple histograms on same plot with Seaborn using Matplotlib?

Advertisements