Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composition update proposal #411

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

brucala
Copy link

@brucala brucala commented Nov 7, 2021

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:

  • The operator + is updated to be used exclusively for layering.
  • The operator * 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:

@vlplot(repeat=...) * (layer1 + layer2)

with this proposal, one could do things like:

data = vlplot(data=...);
facet = vlplot(facet=...)
common_encoding = vlplot(enc=...);
p1 = vlplot(:point, shape=...)
p2 = vlplot(:line, color=...)

data * facet * common_encoding * (p1 + p2)

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.

@brucala
Copy link
Author

brucala commented Nov 16, 2021

@davidanthoff did you have some time to have a look at this proposal and consider it?

@brucala
Copy link
Author

brucala commented Aug 7, 2023

FYI. As a response to this stale PR I have created Deneb.jl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant