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

geom_smooth and patchwork? #401

Closed
emstruong opened this issue Oct 9, 2024 · 1 comment
Closed

geom_smooth and patchwork? #401

emstruong opened this issue Oct 9, 2024 · 1 comment

Comments

@emstruong
Copy link

Hello, there seems to be some issue in putting these two plots together. Is there a way for me to run debug() on the + operator to further investigate what might be going wrong?

library(palmerpenguins)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tidyr)
data(penguins, package = "palmerpenguins")
peng <- penguins |>
  rename(
    bill_length = bill_length_mm, 
    bill_depth = bill_depth_mm, 
    flipper_length = flipper_length_mm, 
    body_mass = body_mass_g
  ) |>
  mutate(species = as.factor(species),
         island = as.factor(island),
         sex = as.factor(substr(sex,1,1))) |>
  tidyr::drop_na()



library(ggdensity)
#> Loading required package: ggplot2
library(patchwork)
p1 <- ggplot(peng, 
             aes(x = bill_length, y = bill_depth,
                 color = species)) +
  geom_smooth(method = "lm",  se=FALSE, linewidth=2) 

p2 <- ggplot(peng, 
             aes(x = bill_length, y = bill_depth,
                 color = species, fill = species)) +
  geom_smooth(method = "lm",  se=FALSE, linewidth=2) 

p1 + p2
#> `geom_smooth()` using formula = 'y ~ x'
#> Error in Ops.data.frame(guide_loc, panel_loc): '==' only defined for equally-sized data frames
p1 | p2
#> `geom_smooth()` using formula = 'y ~ x'
#> Error in Ops.data.frame(guide_loc, panel_loc): '==' only defined for equally-sized data frames
p1 / p2
#> `geom_smooth()` using formula = 'y ~ x'
#> Error in Ops.data.frame(guide_loc, panel_loc): '==' only defined for equally-sized data frames

Created on 2024-10-09 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.2 (2023-10-31)
#>  os       Ubuntu 22.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_CA:en
#>  collate  en_CA.UTF-8
#>  ctype    en_CA.UTF-8
#>  tz       America/Toronto
#>  date     2024-10-09
#>  pandoc   3.2 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/x86_64/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package        * version date (UTC) lib source
#>  cli              3.6.1   2023-03-23 [1] CRAN (R 4.3.0)
#>  colorspace       2.1-0   2023-01-23 [1] CRAN (R 4.3.0)
#>  digest           0.6.33  2023-07-07 [1] CRAN (R 4.3.1)
#>  dplyr          * 1.1.2   2023-04-20 [1] CRAN (R 4.3.0)
#>  evaluate         0.23    2023-11-01 [1] CRAN (R 4.3.1)
#>  fansi            1.0.4   2023-01-22 [1] CRAN (R 4.3.0)
#>  farver           2.1.1   2022-07-06 [1] CRAN (R 4.3.0)
#>  fastmap          1.1.1   2023-02-24 [1] CRAN (R 4.3.0)
#>  fs               1.6.2   2023-04-25 [1] CRAN (R 4.3.0)
#>  generics         0.1.3   2022-07-05 [1] CRAN (R 4.3.0)
#>  ggdensity      * 1.0.0   2023-02-09 [1] CRAN (R 4.3.2)
#>  ggplot2        * 3.5.1   2024-04-23 [1] CRAN (R 4.3.2)
#>  glue             1.6.2   2022-02-24 [1] CRAN (R 4.3.0)
#>  gtable           0.3.3   2023-03-21 [1] CRAN (R 4.3.0)
#>  htmltools        0.5.5   2023-03-23 [1] CRAN (R 4.3.0)
#>  knitr            1.42    2023-01-25 [1] CRAN (R 4.3.0)
#>  labeling         0.4.2   2020-10-20 [1] CRAN (R 4.3.0)
#>  lattice          0.21-9  2023-10-01 [2] CRAN (R 4.3.2)
#>  lifecycle        1.0.3   2022-10-07 [1] CRAN (R 4.3.0)
#>  magrittr         2.0.3   2022-03-30 [1] CRAN (R 4.3.0)
#>  MASS             7.3-60  2023-05-04 [2] CRAN (R 4.3.2)
#>  Matrix           1.6-5   2024-01-11 [1] CRAN (R 4.3.2)
#>  mgcv             1.9-0   2023-07-11 [2] CRAN (R 4.3.2)
#>  munsell          0.5.0   2018-06-12 [1] CRAN (R 4.3.0)
#>  nlme             3.1-162 2023-01-31 [1] CRAN (R 4.3.0)
#>  palmerpenguins * 0.1.1   2022-08-15 [1] CRAN (R 4.3.2)
#>  patchwork      * 1.1.2   2022-08-19 [1] CRAN (R 4.3.0)
#>  pillar           1.9.0   2023-03-22 [1] CRAN (R 4.3.0)
#>  pkgconfig        2.0.3   2019-09-22 [1] CRAN (R 4.3.0)
#>  purrr            1.0.1   2023-01-10 [1] CRAN (R 4.3.0)
#>  R.cache          0.16.0  2022-07-21 [1] CRAN (R 4.3.2)
#>  R.methodsS3      1.8.2   2022-06-13 [1] CRAN (R 4.3.0)
#>  R.oo             1.25.0  2022-06-12 [1] CRAN (R 4.3.0)
#>  R.utils          2.12.2  2022-11-11 [1] CRAN (R 4.3.0)
#>  R6               2.5.1   2021-08-19 [1] CRAN (R 4.3.0)
#>  reprex           2.0.2   2022-08-17 [1] CRAN (R 4.3.0)
#>  rlang            1.1.1   2023-04-28 [1] CRAN (R 4.3.0)
#>  rmarkdown        2.21    2023-03-26 [1] CRAN (R 4.3.0)
#>  rstudioapi       0.14    2022-08-22 [1] CRAN (R 4.3.0)
#>  scales           1.3.0   2023-11-28 [1] CRAN (R 4.3.2)
#>  sessioninfo      1.2.2   2021-12-06 [1] CRAN (R 4.3.1)
#>  styler           1.10.3  2024-04-07 [1] CRAN (R 4.3.2)
#>  tibble           3.2.1   2023-03-20 [1] CRAN (R 4.3.0)
#>  tidyr          * 1.3.0   2023-01-24 [1] CRAN (R 4.3.0)
#>  tidyselect       1.2.0   2022-10-10 [1] CRAN (R 4.3.0)
#>  utf8             1.2.3   2023-01-31 [1] CRAN (R 4.3.0)
#>  vctrs            0.6.5   2023-12-01 [1] CRAN (R 4.3.2)
#>  withr            2.5.2   2023-10-30 [1] CRAN (R 4.3.1)
#>  xfun             0.46    2024-07-18 [1] CRAN (R 4.3.2)
#>  yaml             2.3.7   2023-01-23 [1] CRAN (R 4.3.0)
#> 
#>  [1] /home/XXX/R/x86_64-pc-linux-gnu-library/4.3
#>  [2] /home/XXX/.asdf/installs/r/4.3.2/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@emstruong
Copy link
Author

Fixed with patchwork version 1.3.0

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

1 participant