Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
I'm a big fan of Vega-Lite and python's altair, and I'm very happy that this great julia version exists. I find VegaLite.jl very powerful, however I was initially very confused by the
+
operator. Unfortunately there are no documentation for its usage, other than few examples. After inspecting the code things get more clear, however I still find it not very intuitive and somewhat cumbersome. Then I learnt on several issues (this one in particular) that the whole composition story is not fully finished and that's why there is no proper documentation.Solution proposal
This PR proposes the following solution:
+
is updated to be used exclusively for layering.*
is introduced as a sort of modular composition. This allows to define separately sub components of a plot and put them together via the operator.The sub spec operator proposed in #230 can naturally be done via the
*
operator. This doesn't adjust to the operator precedence discussion in the issue, however in my opinion it is totally natural the need to add the parenthesis in things like:with this proposal, one could do things like:
In my opinion this is a natural way of composing plots. Only after implementing this proposal I also noticed that it's also similar to how the fantastic AlgebraOfGraphics.jl works.
Next steps?
If you like this proposal, I'd be happy to include some tests and update the existing examples. Also, this is a prototype and I'm convinced that there are many ways the composition logic can be improved, happy to hear ideas.