Skip to content

"Reverse" implementation #68

Open
Open

Description

@eliocamp

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).

Activity

  1. eliocamp commented on Jul 18, 2024

    @eliocamp
    OwnerAuthor

    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 a scale_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions