"Reverse" implementation #68
Copy link
Copy link
Open
Description
Currently ggnewscale modifies all previous layers when a new_scale() is added. This means that new scales modify existing scales, making it hard to know the name of the new scales programmatically and also leading to a weird parity error. It also means I cannot add the ability of renaming aes to a particular string ala relayer.
An alternative implementation would change only the subsequent layers and don't touch the existing ones. Because the subsequent layers do not exist when new_scale() is added, then the implementation would "mark" a plot with a custom class with its custom + method and then modify layers as they are added.
I've been experimenting with this in the "reverse-internals" branch (e.g. e91f6d5).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
eliocamp commentedon Jul 18, 2024
A big issue is that if the user doesn't add a layer explicitly after
new_scale()then ggplot2 cannot find the correct scale (it will be looking for ascale_colour_new_continuous()or something like that. A solution would be to add the scale if needed when adding the layer, but it's not trivial to guess the type of scale that is needed. This is not a problem in the other implementation because I can build the plot and extract the relevant scale easily.I'm not sure how to fix this issue.