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

Make add_phylopic work with facets #25

Closed
Bisaloo opened this issue Oct 28, 2019 · 14 comments · Fixed by #48
Closed

Make add_phylopic work with facets #25

Bisaloo opened this issue Oct 28, 2019 · 14 comments · Fixed by #48

Comments

@Bisaloo
Copy link

Bisaloo commented Oct 28, 2019

Hi,

thanks for the great package, I would be interested in making add_phylopic work with ggplot2 facets. The goal would be to be able to put different images in each facets in the following example:

library(ggplot2)
library(rphylopic)

img <- image_data("27356f15-3cf8-47e8-ab41-71c6260b2724", size = "512")[[1]]

ggplot(mpg, aes(displ, hwy)) + 
  geom_point() +
  facet_wrap(~ class) +
  add_phylopic(img)

Created on 2019-10-28 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.1 (2019-07-05)
#>  os       Ubuntu 16.04.6 LTS          
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language en_US                       
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       Europe/Paris                
#>  date     2019-10-28                  
#> 
#> ─ Packages ──────────────────────────────────────────────────────────────
#>  package     * version date       lib source        
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 3.6.0)
#>  backports     1.1.5   2019-10-02 [1] CRAN (R 3.6.1)
#>  callr         3.3.2   2019-09-22 [1] CRAN (R 3.6.1)
#>  cli           1.1.0   2019-03-19 [1] CRAN (R 3.6.0)
#>  colorspace    1.4-1   2019-03-18 [1] CRAN (R 3.6.0)
#>  crayon        1.3.4   2017-09-16 [1] CRAN (R 3.6.0)
#>  crul          0.8.4   2019-08-02 [1] CRAN (R 3.6.1)
#>  curl          4.2     2019-09-24 [1] CRAN (R 3.6.1)
#>  desc          1.2.0   2018-05-01 [1] CRAN (R 3.6.0)
#>  devtools      2.2.1   2019-09-24 [1] CRAN (R 3.6.1)
#>  digest        0.6.21  2019-09-20 [1] CRAN (R 3.6.1)
#>  dplyr         0.8.3   2019-07-04 [1] CRAN (R 3.6.1)
#>  ellipsis      0.3.0   2019-09-20 [1] CRAN (R 3.6.1)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 3.6.0)
#>  fs            1.3.1   2019-05-06 [1] CRAN (R 3.6.0)
#>  ggplot2     * 3.2.1   2019-08-10 [1] CRAN (R 3.6.1)
#>  glue          1.3.1   2019-03-12 [1] CRAN (R 3.6.0)
#>  gridBase      0.4-7   2014-02-24 [1] CRAN (R 3.6.1)
#>  gtable        0.3.0   2019-03-25 [1] CRAN (R 3.6.0)
#>  highr         0.8     2019-03-20 [1] CRAN (R 3.6.0)
#>  htmltools     0.3.6   2017-04-28 [1] CRAN (R 3.6.0)
#>  httpcode      0.2.0   2016-11-14 [1] CRAN (R 3.6.0)
#>  httr          1.4.1   2019-08-05 [1] CRAN (R 3.6.1)
#>  jsonlite      1.6     2018-12-07 [1] CRAN (R 3.6.0)
#>  knitr         1.25    2019-09-18 [1] CRAN (R 3.6.1)
#>  labeling      0.3     2014-08-23 [1] CRAN (R 3.6.0)
#>  lazyeval      0.2.2   2019-03-15 [1] CRAN (R 3.6.0)
#>  magrittr      1.5     2014-11-22 [1] CRAN (R 3.6.0)
#>  memoise       1.1.0   2017-04-21 [1] CRAN (R 3.6.0)
#>  mime          0.7     2019-06-11 [1] CRAN (R 3.6.0)
#>  munsell       0.5.0   2018-06-12 [1] CRAN (R 3.6.0)
#>  pillar        1.4.2   2019-06-29 [1] CRAN (R 3.6.1)
#>  pkgbuild      1.0.5   2019-08-26 [1] CRAN (R 3.6.1)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 3.6.1)
#>  pkgload       1.0.2   2018-10-29 [1] CRAN (R 3.6.0)
#>  png           0.1-7   2013-12-03 [1] CRAN (R 3.6.0)
#>  prettyunits   1.0.2   2015-07-13 [1] CRAN (R 3.6.0)
#>  processx      3.4.1   2019-07-18 [1] CRAN (R 3.6.1)
#>  ps            1.3.0   2018-12-21 [1] CRAN (R 3.6.0)
#>  purrr         0.3.2   2019-03-15 [1] CRAN (R 3.6.0)
#>  R6            2.4.0   2019-02-14 [1] CRAN (R 3.6.0)
#>  Rcpp          1.0.2   2019-07-25 [1] CRAN (R 3.6.1)
#>  remotes       2.1.0   2019-06-24 [1] CRAN (R 3.6.0)
#>  rlang         0.4.0   2019-06-25 [1] CRAN (R 3.6.0)
#>  rmarkdown     1.16    2019-10-01 [1] CRAN (R 3.6.1)
#>  rphylopic   * 0.2.0   2018-11-19 [1] CRAN (R 3.6.1)
#>  rprojroot     1.3-2   2018-01-03 [1] CRAN (R 3.6.0)
#>  scales        1.0.0   2018-08-09 [1] CRAN (R 3.6.0)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.6.0)
#>  stringi       1.4.3   2019-03-12 [1] CRAN (R 3.6.0)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 3.6.0)
#>  testthat      2.2.1   2019-07-25 [1] CRAN (R 3.6.1)
#>  tibble        2.1.3   2019-06-06 [1] CRAN (R 3.6.0)
#>  tidyselect    0.2.5   2018-10-11 [1] CRAN (R 3.6.0)
#>  triebeard     0.3.0   2016-08-04 [1] CRAN (R 3.6.0)
#>  urltools      1.7.3   2019-04-14 [1] CRAN (R 3.6.0)
#>  usethis       1.5.1   2019-07-04 [1] CRAN (R 3.6.1)
#>  withr         2.1.2   2018-03-15 [1] CRAN (R 3.6.0)
#>  xfun          0.10    2019-10-01 [1] CRAN (R 3.6.1)
#>  xml2          1.2.2   2019-08-09 [1] CRAN (R 3.6.1)
#>  yaml          2.2.0   2018-07-25 [1] CRAN (R 3.6.0)
#> 
#> [1] /home/hugo/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library
@sckott
Copy link
Collaborator

sckott commented Oct 30, 2019

great idea @Bisaloo - i've no idea how to do that. sounds like you might have some ideas though?

@Bisaloo
Copy link
Author

Bisaloo commented Oct 31, 2019

Not really but I'm interested enough in this feature to try and have a look at some point. I don't know anything about ggplot internals though so not sure I'll manage to get somewhere.

@sckott
Copy link
Collaborator

sckott commented Oct 31, 2019

Do you know of any examples out there of adding different backgrounds/images to facets already? Then we can build on that

@Bisaloo
Copy link
Author

Bisaloo commented Oct 31, 2019

Hmm, maybe. I would need to have a look in my archives. I won't have time to work on this in the next ~10 days but I'll look into it after that.

@sckott
Copy link
Collaborator

sckott commented Oct 31, 2019

ok, thanks

@Bisaloo
Copy link
Author

Bisaloo commented Nov 4, 2019

Just remembered about this example

library(ggplot2)
library(ggimage)

test <- data.frame("x" = rnorm(4),
                   "y" = rnorm(4),
                   "species" = rep(c(1, 2), 2),
                   "phylopic" = rep(c("c4ac9ea6-b465-4ed0-a5de-9fe4eebd3ef9",
                                      "5388a472-994a-48e1-86de-d988c6019e72"), 2))

ggplot(test, aes(x, y)) +
  geom_point() +
  facet_wrap(~ species) +
  geom_phylopic(aes(image = phylopic))

It's slightly different than what I described in this issue since the phylopic images are used in place of the data points and not as background but it should provide a good basis to think about this issue.

@sckott
Copy link
Collaborator

sckott commented Nov 4, 2019

ah nice, had forgotten about that as well. yes, should provide some guidance on how to proceed for sure

@sckott
Copy link
Collaborator

sckott commented Jun 2, 2020

@Bisaloo still thinking about this? or should we close? no rush at all, just curious

@Bisaloo
Copy link
Author

Bisaloo commented Jun 2, 2020

@sckott, it's on the veryyyy long list of things I'd like to do one day but my schedule is completely full at the moment and for the foreseeable future so do as you see fit with this issue. Thanks!

@sckott
Copy link
Collaborator

sckott commented Jun 2, 2020

okay, will leave it open

@sghignone
Copy link

sghignone commented Feb 22, 2021

hi guy, I'm interested in this topic too. Any news?

@sckott
Copy link
Collaborator

sckott commented Feb 22, 2021

@sghignone you're welcome to contribute. i don't have time myself to work on it

@arw36
Copy link

arw36 commented Sep 13, 2022

Welp, looks like I too am desiring this. I'll look if there is an easy skip around. I'm thinking maybe you can make a grid out of the desired pics, and put them as a geom_rect behind your graph?

@sckott
Copy link
Collaborator

sckott commented Sep 13, 2022

@arw36 I encourage you to see if you can come up with a solution - and submit a PR if you do :)

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

Successfully merging a pull request may close this issue.

4 participants