Move shared encodings of layered charts to top level? #3749
joelostblom
started this conversation in
Ideas
Replies: 2 comments
-
As a user, I really like this syntax. As a user, this discussion may not require my opinion. |
Beta Was this translation helpful? Give feedback.
0 replies
-
A bit related and a bit off-topic, but interesting nonetheless: queryverse/VegaLite.jl#411. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I opened this as a feature request, but maybe it is more of a discussion as a follow up to #2991. The overall sentiment is whether Altair should simplify redundancy in layered specs by moving common encodings to the top level of the Chart instead of repeating them in each layer. I think this is low priority as it would not change any functionality when working in Altair, just the verbosity of the VL spec.
Currently, if we create an Altair spec like this, the code suggests that the encodings are part of the top level chart (
base
) and shared between the marks:However, what actually happens is that the encodings are redundantly copied into the mark of each layer in the Vega-Lite spec:
A more suitable translation would be to include a top-level encoding that can be shared by all the layered marks. This leads to a less verbose Vega-Lite spec that is more semantically similar to how the code is written in Altair:
That VL spec can actually be generated in Altair if we use
LayerChart
directly:I wonder if Altair should try to figure out which encodings are shared between layers and can be moved to the top-level? There is not that much practical benefit from this as the encodings in Altair's grammar can still be thought of conceptually as belonging to the chart and shared by each mark that is added to the chart (even when the code is written as in the first example, it is just that this is not how it works under the hood). I am not sure if there are situations where this automatic move would be undesired.
Beta Was this translation helpful? Give feedback.
All reactions