

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- 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?
- How to create a vertical line in a time series plot in base R?
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- How to plot a time series in Python?
- How to plot two violin plot series on the same graph using Seaborn?
- Plot a lineplot with Seaborn – Python Pandas
Advertisements