Skip to content
Related Articles
Open in App
Not now

Related Articles

Horizontal Stripplot with Jitter using Altair in Python

Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 13 Jan, 2021
Improve Article
Save Article

Prerequisites: Altair

Altair is a statistical data visualization library in python which is based on Vega and Vega-Lite visualization grammars. A Stripplot is used for graphical data analysis.  It is a simple plot of response values in a sorted order along a single axis. The strip plot consists of 2 distinct axes (X, Y). The strip plots provide an alternative for the histogram and other density-based plots and are often used with small datasets. 

A simple strip plot is used for plotting the data as points, which may not be very useful to us. To make the simple stripplot more cultivate we add random jitter. Jitter in simple words is adding a small amount of variability(horizontal or vertical) to the data to ensure all data points are visible. In this article we will discuss how it will be achieved horizontally.


  • Import module
  • Read or create data
  • Now, to create the horizontal stripplot we will interchange our x-axis and y-axis. 
  • Define jitter for the plot
  • Plot the graph 
  • Display plot

Function Used

calculate_transform() allows the user to define new fields in the dataset which are calculated from other fields using an expression.





import altair as alt
import pandas as pd
import numpy as np
df = pd.read_csv(data_url)
horizontal_stripplot = alt.Chart(df, width=600, height=100).mark_circle(size=12).encode(
        axis=alt.Axis(values=[0], ticks=True, grid=False, labels=False),
    x=alt.X('longitude:Q', scale=alt.Scale(domain=(20, 85))),
    color=alt.Color('continent:N', legend=None),
    # Generate Gaussian jitter with a Box-Muller transform



My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!