Altair Heatmap Ticks Text
Is there a way to set the ticks text to a list of strings? I know that ideally it is best to have the ticks directly in the dataset but unfortunately this is not always possible or
Solution 1:
One way to do this is to use the labelExpr
axis attribute, which allows defining new label values using the Vega Expression syntax. For example:
alt.Chart(source).mark_rect().encode(
alt.X('x:O',
axis=alt.Axis(
values=[2*i*np.pi for i inrange(5)],
labelExpr="round(datum.value / PI) + 'π'"
)
),
alt.Y('y:O',
axis=alt.Axis(
labelExpr="round(datum.value / PI) + 'π'"
)
),
color='z:Q'
)
Post a Comment for "Altair Heatmap Ticks Text"