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 PKG is superb + a quick Q #60

Open
sfd99 opened this issue Sep 4, 2024 · 2 comments
Open

ggside PKG is superb + a quick Q #60

sfd99 opened this issue Sep 4, 2024 · 2 comments

Comments

@sfd99
Copy link

sfd99 commented Sep 4, 2024

Hi Justin,

ggside PKG is superb!

  • a quick Q:

Is it possible to add
more than 1 ggside plot
along both the x and y axes?.

ie:
both, a ggside Boxplot
and a ggside Histogram plots
on the x AND also on the Y side of a plot?.
Can you give a concrete, simple R code example?

Thanks!!
sfd99
San Francisco.

@jtlandis
Copy link
Owner

jtlandis commented Sep 5, 2024

Hi @sfd99, I'm glad you find ggside helpful. Just to make sure I understand your question, are you asking if you can add a geom_xsideboxplot() and geom_xsidehistogram() and then also do the same with geom_ysideboxplot() and geom_ysidehistogram()?

library(ggside)
#> Loading required package: ggplot2
#> Registered S3 method overwritten by 'ggside':
#>   method from   
#>   +.gg   ggplot2

# the easy case is adding separate geometries to either side.
ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) +
  geom_point() +
  geom_xsidehistogram(aes(fill = Species)) +
  geom_ysideboxplot(orientation = "x")
#> `stat_xsidebin()` using `bins = 30`. Pick better value with `binwidth`.

# ggside at this moment does not support adding multiple `geom_xside*` geometries
# to the same side but in separate panels. You can however use a less advertised function
# position_rescale(). This function is rather defunct and was added very early in `ggside`'s 
# lifecycle. In-fact, I omitted `position_xrescale()` from the below example because it appears
# to be bugged.
# the intention behind `position_rescale()` is to control where items are rendered in a single
# panel. I haven't yet attempted to make geometries in separate panels because that would
# complicate `ggside`'s compatibility with `facet_grid()`/`facet_wrap()`:
ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) +
  geom_point() +
  geom_xsidehistogram(aes(fill = Species)) +
  geom_xsideboxplot(orientation = "y", 
                    aes(y = as.integer(Species)),
                    position = position_yrescale(range = 25,
                                                 midpoint = 60)) +
  geom_ysidehistogram(aes(fill = Species))
#> `stat_xsidebin()` using `bins = 30`. Pick better value with `binwidth`.
#> `stat_ysidebin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2024-09-04 with reprex v2.1.1

@sfd99
Copy link
Author

sfd99 commented Sep 5, 2024

Hi Justin,

thks for the quick reply!

Yes, that's what I meant:

" ...adding multiple geom_xside* geometries
to the same side
but in separate panels ... ".

Understood,
it's NA (reliably) presently in the pkg .

But...
do keep the feature in mind
for future versions of the great ggside PKG!. :-)

Thanks!
sfd99
San Francisco.

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