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

ggside doesn't work with coord_cartesian #55

Closed
The-Dub opened this issue Feb 21, 2024 · 2 comments
Closed

ggside doesn't work with coord_cartesian #55

The-Dub opened this issue Feb 21, 2024 · 2 comments

Comments

@The-Dub
Copy link

The-Dub commented Feb 21, 2024

Hello,

First of all thank you for this wonderful package, that makes it very easy to add marginal distribution.

I have encountered an issue that is easily reproducible : when using ggplot::coord_cartesian, it changes the x and y lim of the main plot, but also the limits of the xside and yside, that is not a wanted behavior, from what I understand.

library(tidyverse)
library(ggside)

ggplot(mpg, aes(displ, hwy, colour = class)) + 
  geom_point(size = 2) +
  geom_xsidedensity(aes(y = after_stat(density)), position = "stack") +
  geom_ysidedensity(aes(x = after_stat(density)), position = "stack") +
  theme(axis.text.x = element_text(angle = 90, vjust = .5)) + 
  coord_cartesian(xlim = c(3, 6), ylim = c(20, 30))

I have tried to overwrite this behavior with scale_xsidey_continuous and scale_ysidex_continuous without any success. I have found the function as_ggsideCoord but I'm unsure how this function works. The ggside documentation for the scale*_side_function states that one should use coord_cartesiant ("If the purpose is to zoom, use the limit argument in the coordinate system (see coord_cartesian()).")

Thank you for the help

@jtlandis
Copy link
Owner

This is most definitely a bug - I'll try and investigate where it pops up in the code

@jtlandis
Copy link
Owner

Thankfully, this should was a relatively easy hotfix in c6c1082 that I could complete this in a day. If you find any more errors or unexpected behaviors, please do not hesitate to drop another issue.

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

No branches or pull requests

2 participants