- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- 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
How to plot a time series graph using Seaborn or Plotly?
To plot a time series graph using Seaborn or Plotly, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create a Pandas dataframe, df, to hold a date_time series "time" and another variable data, speed.
- Make a Seaborn line plot with the data, "time" and "speed"
- Rotate the tick params by 45.
- To display the figure, use show() method.
import seaborn as sns from matplotlib import pyplot as plt import pandas as pd import numpy as np plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame( dict( time=list(pd.date_range("2021-01-01 12:00:00", periods=10, freq="30min")), speed=np.linspace(1, 10, 10) ) ) ax = sns.lineplot(x="time", y="speed", data=df) ax.tick_params(rotation=45) plt.show()
It will produce the following output
- Related Articles
- How to plot two violin plot series on the same graph using Seaborn?
- Python - Create a Time Series Plot using Line Plot with Seaborn
- How to plot multiple time series using ggplot2 in R?
- How to plot a time series in Python?
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- Python - Create a Time Series Plot with multiple columns using Line Plot
- How to create a time series plot in R without time vector?
- How to convert ggplot2 graph into a plotly graph in R?
- How to plot a non-square Seaborn jointplot or JointGrid? (Matplotlib)
- How to plot a bar graph in Matplotlib from a Pandas series?
- How to plot multiple histograms on same plot with Seaborn using Matplotlib?
- How to remove or hide X-axis labels from a Seaborn / Matplotlib plot?
- Plotting graph using seaborn in python.
- How do you plot a vertical line on a time series plot in Pandas?
- How to add a legend on Seaborn facetgrid bar plot using Matplotlib?