Reputation: 561
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.
Upvotes: 1
Views: 1230
Reputation: 48929
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)
Upvotes: 4