Timeseries

Timeseries with python

Timeseries charts refer to all charts representing the evolution of a numeric value. Line chart, streamgraph, barplot, area chart: they all can be used for timeseries visualization. This section displays many timeseries examples made with Python, Matplotlib and other libraries.

⏱ Quick start

# libraries
  import matplotlib.pyplot as plt
  import numpy as np

  # create data
  values=np.cumsum(np.random.randn(1000,1))

  # use the plot function
  plt.plot(values)
  

Area charts for timeseries

Area charts are very often used for timeseries visualization. They are particularly adapted when there is only 1 series to display. When several groups must be displayed, they can still be used using faceting.

Line charts for timeseries

Line charts are probably the most common type of viz for timeseries. They are particularly adapted when several groups must be displayed to compare their evolution. But mind the spaghetti plot: too many groups make the figure unreadable.

Candlesticks

A candlestick chart is a style of financial chart used to describe price movements. Each "candlestick" typically shows one day, with the Open, High, Low, and Close (OHLC) values for each day.

Here are examples using mplfinance from matplotlib to display the evolution of different prices.

Matplotlib logoBest python timeseries examples

A set of publication ready charts for timeseries. They are made with Python and libraries like Matplotlib orPlotly and use a high level of customization.

The first example is a line chart showing how to add labels at the end of each series for better readability. The second shows how to use lollipop to display the evolution of a deviation around a trend. The last one shows how to use an area over a flexible baseline to display the deviation around a historical reference period.

Contact


👋 This document is a work by Yan Holtz. You can contribute on github, send me a feedback on twitter or subscribe to the newsletter to know when new examples are published! 🔥