Suppose I had the following plot (taken from the tutorial in the Altair documentation):
import altair as alt
from vega_datasets import data
alt.Chart(data.cars()).transform_density(
'Miles_per_Gallon',
as_=['Miles_per_Gallon', 'density'],
extent=[5, 50],
groupby=['Origin']
).mark_area(orient='horizontal').encode(
y='Miles_per_Gallon:Q',
color='Origin:N',
x=alt.X(
'density:Q',
stack='center',
impute=None,
title=None,
axis=alt.Axis(labels=False, values=[0],grid=False, ticks=True),
),
column=alt.Column(
'Origin:N',
header=alt.Header(
titleOrient='bottom',
labelOrient='bottom',
labelPadding=0,
),
)
).properties(
width=100
).configure_facet(
spacing=0
).configure_view(
stroke=None
)
How would I got about drawing quartile and median lines on each of those violin plots? Would I have to define another plot and layer it on top of the violin plots? It would also be nice if the lines are the same width as the violin plot at the specific location on the distribution.



