Replies: 2 comments 3 replies
-
This might be combining two ideas, but I guess where I'm going with this is it would be nice to retroactively change title, xlabel, ylabel, at the end. This will allow for neat organization, concise chart code above, and one single location for tinkering with labels: alt.Chart(df).mark_line().encode(
x="X:O",
y="Y:Q"
).properties(
title="Title",
xlabel="X Label",
ylabel="Y Label (units)"
) I find it much cleaner and more readable than: alt.Chart(
df,
title="Title"
).mark_line().encode(
x=alt.X("X:O", axis=alt.Axis(title="X Label"),
y=alt.Y("Y:Q", axis=alt.Axis(title="Y Label (units)")
) |
Beta Was this translation helpful? Give feedback.
-
I believe properties takes any of the parameters that go into alt.Chart(df).mark_line().encode(
x="X:O",
y="Y:Q"
).properties(
title="Title"
).configure_axisX(
title="X Title"
).configure_axisY(
title="Y Title"
) Although I don't find this clearer than using the more common syntax (note that the alt.Chart(df, title="Title").mark_line().encode(
x=alt.X("X:O").title("X Title"),
y=alt.Y("Y:Q").title("Y Title (units)")
) I guess that underneath this, there is a theory/philosophy decision taken in the Altair/Vega-Lite grammar of whether all things related to the one encoding (values, labels, titles) belong together, or whether all things of the same type belong together (all labels (X, Y, Color, etc) separate from all titles etc). Personally, I quite like having all things that belong to the same encoding in one place, particularly when doing modifications to e.g. the title offset that would be different for x and y (but I understand this preference differs) |
Beta Was this translation helpful? Give feedback.
-
The docs mention setting title with
alt.Chart(df, title="")
. I'm not sure where I picked it up as I cannot find it in the docs, but I am accustomed to usingalt.Chart().properties(title="")
.What is the difference why is only one discussed?
Beta Was this translation helpful? Give feedback.
All reactions