3.7 Lollipop Chart

A lollipop plot is a hybrid between a scatter plot and a barplot. It shows the relationship between a numerical variable and another variable, numerical or categorical. It's better to decrease the order and represent horizontal lines.

First, Let's create a dataset.

# Create a dataset
df = pd.DataFrame({'group':list(map(chr, range(70, 90))), 'values':np.random.uniform(size=20)})

ordered_df = df.sort_values(by='values')  # reorder it by 'values'   
my_range=range(1,len(df.index)+1)         # calcaulate data range

1. Univariate Lollipop

Figure: Univariate Lollipop

2. Highlight Lollipop

Moreover, we .can add some eye-catching features for storytelling. For example, highlight a group that specifically interests you with a bigger size and different colors.

Figure: Highlight Lollipop

3. Multivariate Lollipop

We can use multi-variables lollipop if you have more than one observation for each group. Instead of displaying the values of both groups one beside each other, show them on the same line, and represent the difference.

Now we need to create a new dataset with two variables.

Figure: Multivariate Lollipop

Last updated

Was this helpful?