
- 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 using Line Plot with Seaborn
To create a Time Series 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 with one of the columns as date i.e. “Date_of_Purchase” −
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, 45, 70, 70, 87, 66] })
Pot Time Series using lineplot() −
sb.lineplot(x="Date_of_Purchase", y="Units Sold", 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, 45, 70, 70, 87, 66] }) # time series plot sb.lineplot(x="Date_of_Purchase", y="Units Sold", data=dataFrame) plt.show()
Output
This will produce the following output −
- Related Articles
- Python - Create a Time Series Plot with multiple columns using Line Plot
- How to plot a time series graph using Seaborn or Plotly?
- Create a Scatter Plot with SeaBorn – Python Pandas
- Create a Box Plot with SeaBorn – Python Pandas
- Create a Violin Plot with SeaBorn – Python Pandas
- Create a Swarm Plot with SeaBorn – Python Pandas
- Create a Bar plot with SeaBorn – Python Pandas
- Create a Point plot with SeaBorn – Python Pandas
- Create a Count Plot with SeaBorn – Python Pandas
- How do you plot a vertical line on a time series plot in Pandas?
- Plot a lineplot with Seaborn – Python Pandas
- How to plot two violin plot series on the same graph using Seaborn?
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- How to create a vertical line in a time series plot in base R?\n
- Python Pandas - Create a Count Plot and style the bars with Seaborn

Advertisements