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

Border always cut off in .png or .svg #155

Open
schckngs opened this issue Mar 14, 2022 · 4 comments
Open

Border always cut off in .png or .svg #155

schckngs opened this issue Mar 14, 2022 · 4 comments

Comments

@schckngs
Copy link

Hey, thanks for this cool package. I've made a sticker but can't seem to figure out why the left side and bottom of the border are always cut off.
I've tried on a windows and mac, R version 4.0.2. (magick version 2.6.0, hexSticker 0.4.9)
Running one of the examples:

library(lattice)
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
bwplot <- bwplot(counts ~ outcome | treatment, xlab=NULL, ylab=NULL, cex=.5,
                 scales=list(cex=.5), par.strip.text=list(cex=.5))

sticker(bwplot, package="hexSticker", p_size=20, s_x=1.05, s_y=.8, s_width=2, s_height=1.5,
        h_fill="#f9690e", h_color="#f39c12", filename="lattice.png")

The result is attached

lattice

@schckngs
Copy link
Author

I fixed this by adjusting the theme_sticker() function - the margin shift was causing this issue on my computer:
theme(plot.margin = margin(b = -.2, l= -.2, unit = "lines")
By removing b and l (or setting to zero) it works perfectly. I'm curious if anyone else has this happen.

@GuangchuangYu
Copy link
Owner

I don't have this issue. Here is my session info:

> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS:   /usr/lib/libblas.so.3.10.0
LAPACK: /usr/lib/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] hexSticker_0.4.9      lattice_0.20-45       yulab.utils_0.0.4.901
[4] magrittr_2.0.2        conflicted_1.1.0      rvcheck_0.2.1        
[7] wget_0.0.1            rmarkdown_2.13       

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.2    xfun_0.30           purrr_0.3.4        
 [4] ggfun_0.0.5         colorspace_2.0-3    vctrs_0.3.8        
 [7] generics_0.1.2      htmltools_0.5.2     utf8_1.2.2         
[10] gridGraphics_0.5-1  rlang_1.0.2         hexbin_1.28.2      
[13] pillar_1.7.0        glue_1.6.2          DBI_1.1.2          
[16] lifecycle_1.0.1     munsell_0.5.0       gtable_0.3.0       
[19] ragg_1.2.2          memoise_2.0.1       evaluate_0.15      
[22] labeling_0.4.2      knitr_1.37          fastmap_1.1.0      
[25] fansi_1.0.2         Rcpp_1.0.8.3        scales_1.1.1       
[28] BiocManager_1.30.16 cachem_1.0.6        showtext_0.9-5     
[31] magick_2.7.3        jsonlite_1.8.0      sysfonts_0.8.8     
[34] farver_2.1.0        systemfonts_1.0.4   textshaping_0.3.6  
[37] ggplot2_3.3.5       digest_0.6.29       dplyr_1.0.8        
[40] showtextdb_3.0      grid_4.1.3          ggimage_0.3.0      
[43] cli_3.2.0           tools_4.1.3         tibble_3.1.6       
[46] crayon_1.5.0        pkgconfig_2.0.3     ellipsis_0.3.2     
[49] ggplotify_0.1.0     assertthat_0.2.1    R6_2.5.1           
[52] compiler_4.1.3     
> 

@schckngs Can you post yours?

Maybe it is OS-depended.

@tentacles-from-outer-space

Don't know if it is the same cause, but similar results are when I change h_size

library(hexSticker)
#> Warning: package 'hexSticker' was built under R version 4.1.3
library(ggplot2)
plot(sticker(
  ggplot(x = 1, y = 1)
  ,package = "bordersCut it's sad"
  ,h_size = 8
))
#> Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments

Created on 2022-06-15 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language en
#>  collate  Polish_Poland.1250
#>  ctype    Polish_Poland.1250
#>  tz       Europe/Warsaw
#>  date     2022-06-15
#>  pandoc   2.17.1.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package      * version date (UTC) lib source
#>  assertthat     0.2.1   2019-03-21 [1] CRAN (R 4.1.2)
#>  cli            3.2.0   2022-02-14 [1] CRAN (R 4.1.2)
#>  colorspace     2.0-3   2022-02-21 [1] CRAN (R 4.1.2)
#>  crayon         1.5.1   2022-03-26 [1] CRAN (R 4.1.3)
#>  curl           4.3.2   2021-06-23 [1] CRAN (R 4.1.2)
#>  DBI            1.1.2   2021-12-20 [1] CRAN (R 4.1.2)
#>  digest         0.6.29  2021-12-01 [1] CRAN (R 4.1.2)
#>  dplyr          1.0.8   2022-02-08 [1] CRAN (R 4.1.2)
#>  ellipsis       0.3.2   2021-04-29 [1] CRAN (R 4.1.2)
#>  evaluate       0.15    2022-02-18 [1] CRAN (R 4.1.2)
#>  fansi          1.0.3   2022-03-24 [1] CRAN (R 4.1.3)
#>  farver         2.1.0   2021-02-28 [1] CRAN (R 4.1.2)
#>  fastmap        1.1.0   2021-01-25 [1] CRAN (R 4.1.2)
#>  fs             1.5.2   2021-12-08 [1] CRAN (R 4.1.3)
#>  generics       0.1.2   2022-01-31 [1] CRAN (R 4.1.2)
#>  ggfun          0.0.6   2022-04-01 [1] CRAN (R 4.1.3)
#>  ggimage        0.3.1   2022-04-25 [1] CRAN (R 4.1.3)
#>  ggplot2      * 3.3.5   2021-06-25 [1] CRAN (R 4.1.2)
#>  ggplotify      0.1.0   2021-09-02 [1] CRAN (R 4.1.3)
#>  glue           1.6.2   2022-02-24 [1] CRAN (R 4.1.2)
#>  gridGraphics   0.5-1   2020-12-13 [1] CRAN (R 4.1.3)
#>  gtable         0.3.0   2019-03-25 [1] CRAN (R 4.1.2)
#>  hexbin         1.28.2  2021-01-08 [1] CRAN (R 4.1.3)
#>  hexSticker   * 0.4.9   2020-12-05 [1] CRAN (R 4.1.3)
#>  highr          0.9     2021-04-16 [1] CRAN (R 4.1.2)
#>  htmltools      0.5.2   2021-08-25 [1] CRAN (R 4.1.2)
#>  httr           1.4.2   2020-07-20 [1] CRAN (R 4.1.2)
#>  jsonlite       1.8.0   2022-02-22 [1] CRAN (R 4.1.2)
#>  knitr          1.38    2022-03-25 [1] CRAN (R 4.1.3)
#>  labeling       0.4.2   2020-10-20 [1] CRAN (R 4.1.1)
#>  lattice        0.20-45 2021-09-22 [1] CRAN (R 4.1.2)
#>  lifecycle      1.0.1   2021-09-24 [1] CRAN (R 4.1.2)
#>  magick         2.7.3   2021-08-18 [1] CRAN (R 4.1.3)
#>  magrittr       2.0.2   2022-01-26 [1] CRAN (R 4.1.2)
#>  mime           0.12    2021-09-28 [1] CRAN (R 4.1.1)
#>  munsell        0.5.0   2018-06-12 [1] CRAN (R 4.1.2)
#>  pillar         1.7.0   2022-02-01 [1] CRAN (R 4.1.2)
#>  pkgconfig      2.0.3   2019-09-22 [1] CRAN (R 4.1.2)
#>  purrr          0.3.4   2020-04-17 [1] CRAN (R 4.1.2)
#>  R6             2.5.1   2021-08-19 [1] CRAN (R 4.1.2)
#>  ragg           1.2.2   2022-02-21 [1] CRAN (R 4.1.2)
#>  Rcpp           1.0.8.3 2022-03-17 [1] CRAN (R 4.1.3)
#>  reprex         2.0.1   2021-08-05 [1] CRAN (R 4.1.2)
#>  rlang          1.0.2   2022-03-04 [1] CRAN (R 4.1.2)
#>  rmarkdown      2.13    2022-03-10 [1] CRAN (R 4.1.3)
#>  rstudioapi     0.13    2020-11-12 [1] CRAN (R 4.1.2)
#>  scales         1.1.1   2020-05-11 [1] CRAN (R 4.1.2)
#>  sessioninfo    1.2.2   2021-12-06 [1] CRAN (R 4.1.2)
#>  showtext       0.9-5   2022-02-09 [1] CRAN (R 4.1.2)
#>  showtextdb     3.0     2020-06-04 [1] CRAN (R 4.1.2)
#>  stringi        1.7.6   2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr        1.4.0   2019-02-10 [1] CRAN (R 4.1.2)
#>  sysfonts       0.8.8   2022-03-13 [1] CRAN (R 4.1.3)
#>  systemfonts    1.0.4   2022-02-11 [1] CRAN (R 4.1.2)
#>  textshaping    0.3.6   2021-10-13 [1] CRAN (R 4.1.2)
#>  tibble         3.1.6   2021-11-07 [1] CRAN (R 4.1.2)
#>  tidyselect     1.1.2   2022-02-21 [1] CRAN (R 4.1.2)
#>  utf8           1.2.2   2021-07-24 [1] CRAN (R 4.1.2)
#>  vctrs          0.3.8   2021-04-29 [1] CRAN (R 4.1.2)
#>  withr          2.5.0   2022-03-03 [1] CRAN (R 4.1.2)
#>  xfun           0.30    2022-03-02 [1] CRAN (R 4.1.2)
#>  xml2           1.3.3   2021-11-30 [1] CRAN (R 4.1.2)
#>  yaml           2.3.5   2022-02-21 [1] CRAN (R 4.1.2)
#>  yulab.utils    0.0.4   2021-10-09 [1] CRAN (R 4.1.3)
#> 
#>  [1] C:/xxxxxxxxx/r-library/4.1
#>  [2] C:/Program Files/R/R-4.1.2/library
#> 
#> ------------------------------------------------------------------------------

@cyrusae
Copy link

cyrusae commented Oct 21, 2022

Same bug for me when changing h_size now (first-time install today). Leaving session info in case it's helpful:

RStudio Version
--------------------------------------------------
2022.07.0+548


Session Information
--------------------------------------------------
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
 [1] rsvg_2.3.1       svglite_2.1.0    magick_2.7.3    
 [4] ggplot2_3.3.6    patchwork_1.1.2  png_0.1-7       
 [7] hexSticker_0.4.9 showtext_0.9-5   showtextdb_3.0  
[10] sysfonts_0.8.8  

loaded via a namespace (and not attached):
 [1] bslib_0.3.1        tidyselect_1.1.2   xfun_0.31         
 [4] purrr_0.3.4        lattice_0.20-45    ggfun_0.0.7       
 [7] colorspace_2.0-3   vctrs_0.4.1        generics_0.1.3    
[10] htmltools_0.5.2    yaml_2.3.5         utf8_1.2.2        
[13] gridGraphics_0.5-1 rlang_1.0.6        jquerylib_0.1.4   
[16] hexbin_1.28.2      pillar_1.8.0       glue_1.6.2        
[19] withr_2.5.0        DBI_1.1.3          lifecycle_1.0.1   
[22] stringr_1.4.0      munsell_0.5.0      gtable_0.3.0      
[25] ragg_1.2.2         evaluate_0.15      labeling_0.4.2    
[28] knitr_1.39         fastmap_1.1.0      curl_4.3.2        
[31] fansi_1.0.3        Rcpp_1.0.9         scales_1.2.0      
[34] jsonlite_1.8.0     farver_2.1.1       systemfonts_1.0.4 
[37] textshaping_0.3.6  digest_0.6.29      stringi_1.7.8     
[40] dplyr_1.0.9        grid_4.2.1         ggimage_0.3.1     
[43] cli_3.3.0          tools_4.2.1        yulab.utils_0.0.5 
[46] sass_0.4.1         magrittr_2.0.3     tibble_3.1.7      
[49] pkgconfig_2.0.3    ellipsis_0.3.2     ggplotify_0.1.0   
[52] assertthat_0.2.1   rmarkdown_2.14     rstudioapi_0.13   
[55] R6_2.5.1           compiler_4.2.1    

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

4 participants