I'm trying to create a line chart with point markers in Altair. I'm using the multi-series line chart example from Altair's documentation and trying to combine it with the line chart with stroked point markers example from Vega-Lite's documentation.
Where I'm confused is how to handle the 'mark_line' argument. From the Vega example, I need use "point" and then set "filled" to False.
"mark": {
"type": "line",
"point": {
"filled": false,
"fill": "white"
}
},
How would I apply that in Altair? I figured out that setting 'point' to 'True' or '{}' added a point marker, but confused on how to get the fill to work.
source = data.stocks()
alt.Chart(source).mark_line(
point=True
).encode(
x='date',
y='price',
color='symbol'
)
You can always pass a raw vega-lite dict to any property in Altair:
source = data.stocks()
alt.Chart(source).mark_line(
point={
"filled": False,
"fill": "white"
}
).encode(
x='date',
y='price',
color='symbol'
)
or you can check the docstring of mark_line()
and see that it expects point to be an OverlayMarkDef()
and use the Python wrappers:
alt.Chart(source).mark_line(
point=alt.OverlayMarkDef(filled=False, fill='white')
).encode(
x='date',
y='price',
color='symbol'
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.