'Altair: Customizing outliers in boxplots
Is there any way to customize the outlier points in an Altair boxplot? Suppose I had the following plot:
penguins_data="https://raw.githubusercontent.com/datavizpyr/data/master/palmer_penguin_species.tsv"
penguins_df = pd.read_csv(penguins_data, sep="\t")
chart = alt.Chart(penguins_df).mark_boxplot(size=50, extent=0.5).encode(
x='species:O',
y=alt.Y('culmen_length_mm:Q',scale=alt.Scale(zero=False)),
color=alt.Color('species')
).properties(width=300)
I would like to jitter the outliers and also make the points smaller. Is that possible, or would we have to create two layered plots? Ideally the jittered points are all found within the width of the boxplot itself, but that isn't necessary.
Solution 1:[1]
I don't think you can jitter them, but you can make them smaller:
alt.Chart(penguins_df).mark_boxplot(size=50, extent=0.5, outliers={'size': 5}).encode(
x='species:O',
y=alt.Y('culmen_length_mm:Q',scale=alt.Scale(zero=False)),
color=alt.Color('species')
).properties(width=300)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | joelostblom |