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.
This PR has a proof of concept for a "compound mark" concept (cf #2991). In this implementation, marks are combined through the addition operator (e.g.
Dot() + Range()
):A potentially useful (but also potentially surprising) behavior is that the second mark will inherit any properties set directly on the first mark:
(We could decide that this is too magical to be helpful).
Mark properties are mapped together:
Compound marks also move together and simplify some existing edge cases (cf. #2987)
Open questions
Is overloading
Mark.__add__
the right approach here? It would be the only place where a mathematical operator is overloaded to build a plot. And we need to be mindful of the adjacency to ggplot syntax, which uses+
overloading for everything. There's also potentially the odd tension of having this operation happening within a method called.add
.Alternatives considered:
CompoundMark
a public object and use it, possibly setting common properties with kwargs, e.g.CompoundMark(Dot(), Range(), color="r")
Plot.add
with the same general logic, e.g.Plot().add([Dot(), Range()], Est())
Plot.add
signature to be*args
and then work out what's what based on types e.g.Plot().add(Dot(), Range(), Est(), Dodge())
My current thinking is that these are, in turn, too verbose / too fussy with brackets / too opaque when read. But I'm not completely sold on addition overloading...
Needs