Connected Scatterplot
A connected scatterplot is a line chart where each data point is shown by a circle or any type of marker. This section explains how to build a connected scatterplot with Python
, using both the Matplotlib
and the Seaborn
libraries.
⏱ Quick start
# library
import seaborn as sns
import pandas as pd
import numpy as np
# Create a dataset
df = pd.DataFrame(np.random.random((5,5)), columns=["a","b","c","d","e"])
# Default heatmap
p1 = sns.heatmap(df)
⚠️ Two types of connected scatterplot
There are two types of connected scatterplot, and it often creates confusion.
The first is simply a lineplot with dots added on top of it. It takes as input 2 numeric variables only. The second shows the relationship between 2 numeric variables across time. It requires 3 numeric variables as input.
Confusing? Visit data-to-viz to clarify..
Connected scatterplot with Seaborn
Building a connected scatterplot with Seaborn
looks pretty much the same as for a line chart, so feel free to visit the related section. Here are a few examples to remind the basics and understand how to customize the markers.
Connected scatterplot with Matplotlib
As for scatterplots, Matplotlib
will help us build a bubble plot thanks to the the plt.scatter()
function. This function provides a s
parameter allowing to pass a third variable that will be mapped to the markers size.
Cheatsheet: line customization with Matplotlib
and the linestyle
parameter.
Connected scatterplot for 2 variables
As explained above, a connected scatterplot can also be base on 3 numeric variables. It allows to study the evolution of 2 variables (placed on the X and on the Y axis).
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
.