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

Allow position aesthetics other than x and y? #3898

Open
paleolimbot opened this issue Mar 16, 2020 · 5 comments
Open

Allow position aesthetics other than x and y? #3898

paleolimbot opened this issue Mar 16, 2020 · 5 comments
Labels
feature a feature request or enhancement internals 🔎

Comments

@paleolimbot
Copy link
Member

This is an issue so that we remember to come back to this. As noted by. @clauswilke here: #3561 (comment) , constructing ternary diagrams using ggplot requires a lot of copying of ggplot2 code, which has resulted in the current breaking of the ggtern package.

At the heart of the issue is that a ternary diagram is a transformation of 3 variables, rather than 2. Currently, x- and y-scales are hard-coded in the Layout and other places, which makes adding an additional aesthetic that should be treated as a position aesthetic impossible (see #2540 (comment) ). I can't find the thread, but this came up in the context of coord_sf(), where geometry is also sort of a position aesthetic (that only sort of acts like one).

One approach would be to allow coords to define what is a position aesthetic. Currently there are a lot of definitions of "what is a position aesthetic" (#3342). If I remember correctly, this will break Coord and possibly Facet subclasses that are passed scale_x and scale_y.

Anyway, not pressing, just something that should be considered when coords are revisited.

@teunbrand
Copy link
Collaborator

To add another use case besides ternary diagrams, a z position aesthetic is also useful for plotting 3D structures projected onto 2D, similar to graphics::persp().

@clauswilke
Copy link
Member

Discussion of geometry scales happened here: #3659 (comment)

@thomasp85
Copy link
Member

I think this is a good discussion to take, but not of high priority. It would be nice to come up with a more extendible setup than what we currently have

@davidchall
Copy link

Similar to @teunbrand's use case of mapping 3D to 2D, I think there are also use cases that map 1D to 2D.

  • For example my ggip package maps IP addresses to a 2D grid using a space-filling curve. I borrowed some ideas from coord_sf() to get this to work.
  • Similarly, the HilbertCurve package maps genomic data to the 2D plane, though is not a ggplot2 extension.

@hughjonesd
Copy link

This may not be exactly the same issue, but I have a ggplot extension which defines multiple x and y aesthetics (4 to be exact). I'd like to be able to tell scales "hey, this is an x aesthetic, please transform it according to your trans". So, basically, I want to be able to modify ggplot_global$x_aes, locally for my geom. Cf. #4135.

I can apply the transformation manually in Stat$compute_group(), but it's cumbersome and leads to ad hoc code. It also doesn't have access to aesthetics that were set, rather than scaled. Conversely, Stat$finish_data() has access to those aesthetics but not to the scale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement internals 🔎
Projects
None yet
Development

No branches or pull requests

6 participants