Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide facet title in Altair chart?

Tags:

python

altair

Given a simple, faceted chart like:

import altair as alt

data = alt.Data(values = [
    { "category" : "a", "x" : 1, "y" : 2 },
    { "category" : "a", "x" : 2, "y" : 4 },
    { "category" : "b", "x" : 1, "y" : 3 },
    { "category" : "b", "x" : 2, "y" : 5 }
])

alt.Chart(data).mark_point().encode(x = "x:Q", y = "y:Q").facet(
    row = "category:O"
)

How do you hide the top-level "category" title along the y axis (while keeping the "a" and "b" labels)?

chart

like image 675
ejain Avatar asked Sep 20 '25 18:09

ejain


1 Answers

You can set the title property of the encoding to None:

alt.Chart(data).mark_point().encode(x = "x:Q", y = "y:Q").facet(
    row = alt.Row("category:O", title=None)
)

enter image description here

like image 139
jakevdp Avatar answered Sep 22 '25 09:09

jakevdp