Line Chart


A line chart displays the evolution of one or several numeric variables. It is one of the most common chart type, so it can be build using any python viz library, like matplotlib, seaborn or plotly.

⏱ Quick start

Making a simple line chart with matplotlib is pretty straightforward thanks to the plot() function.

If you provide only a series of values, it will consider that these values are ordered and will use values from 1 to n to create the X axis.🔥

For more control on the chart, see the dedicated section below.

# 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)

Matplotlib logoLine chart with Matplotlib

Matplotlib is a great fit to build line charts thanks to its plot() function. The first chart of this section explains how to use plot() from any kind of data input format. The next one goes deep into chart customization (line width, color aspect and more).

Matplotlib logoLine chart with several groups (Matplotlib)

A line chart with multiple groups allows to show the evolution of several items on the same figure. It is powerful but can quickly turn into a spaghetti chart: when too many lines are displayed they get hard to read. The examples below explain how to build one, and what are the alternative to show your data a better way.

Contact

👋 This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message onTwitter, or send an email pasting yan.holtz.data with gmail.com.

Violin

Density

Histogram

Boxplot

Ridgeline

Scatterplot

Heatmap

Correlogram

Bubble

Connected Scatter

2D Density

Barplot

Spider / Radar

Wordcloud

Parallel

Lollipop

Circular Barplot

Treemap

Venn Diagram

Donut

Pie Chart

Dendrogram

Circular Packing

Line chart

Area chart

Stacked Area

Streamgraph

Map

Choropleth

Hexbin

Cartogram

Connection

Bubble

Chord Diagram

Network

Sankey

Arc Diagram

Edge Bundling

Colors

Interactivity

Animation with python

Animation

Cheat sheets

Caveats

3D