Skip to content

Record example plots with device requested in figures field instead of ragg::agg_png() #2299

Closed

Description

@trevorld
  • I have examples that work if the active graphics device supports the "affine transformation" feature introduced in R 4.2+. This is true if isTRUE(dev.capabilities()$transformations). grDevices::png(type = "cairo") is an example of a graphics device that supports this feature whereas rag::agg_png() is an example of a graphics device that (as of 2023-04-18) does not support this feature.

  • Because this example doesn't work unless the active graphics device supports this feature I have the example protected by an if(isTRUE(dev.capabilities()$transformations)) {}.

  • However when I build the {pkgdown} site this example is skipped even though I've requested using grDevices::png(type = "cairo") to render the figures in the figures field in _pkgdown.yml:

    figures:
      dev: grDevices::png
      dev.args:
        type: "cairo"
  • It seems that {pgkdown} first runs the examples using ragg::agg_png() as the active graphics device, records the plots using grDevices::recordPlot(), and then rendering them in the requested graphics device using grDevices::replayPlot()?

  • However this workflow doesn't work well in my case because if ragg::agg_png() is the active graphics device my example is skipped because ragg::agg_png() doesn't support (yet) the affine transformations feature. It would be better if instead the plots were recorded with the requested grDevices::png(type = "cairo") device instead.

  • I've created a minimal R package illustrating my issue: https://github.com/trevorld/pkgbuild.pngdev

    The repository also has a Dockerfile that 1) builds the development version of {pkgdown}, 2) builds the package documentation site, 3) serves the documentation site on port 3000

  • In the docker {pkgdown} rendered version of the my example I observe the following session info and graphics device settings:

print(pkgdown::fig_settings())
$dev
[1] "grDevices::png"

$dpi
[1] 96

$dev.args
$dev.args$type
[1] "cairo"


$fig.ext
[1] "png"

$fig.width
[1] 7.291667

$fig.height
[1] 4.506593

$fig.retina
[1] 2

$fig.asp
[1] 0.618047

$bg
NULL

$other.parameters
list()
print(names(dev.cur()))
[1] "agg_png"
print(isTRUE(dev.capabilities()$transformations))
[1] FALSE
print(sessionInfo())
R version 4.2.3 (2023-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux bookworm/sid

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.21.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
 [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] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] pkgbuild.pngdev_0.1.0-1

loaded via a namespace (and not attached):
 [1] whisker_0.4.1      xml2_1.3.3         knitr_1.42         magrittr_2.0.3    
 [5] downlit_0.4.2      R6_2.5.1           ragg_1.2.5         rlang_1.1.0       
 [9] fastmap_1.1.1      fansi_1.0.4        httr_1.4.5         tools_4.2.3       
[13] xfun_0.38          utf8_1.2.3         cli_3.6.1          withr_2.5.0       
[17] systemfonts_1.0.4  htmltools_0.5.5    yaml_2.3.7         rprojroot_2.0.3   
[21] digest_0.6.31      tibble_3.2.1       lifecycle_1.0.3    pkgdown_2.0.7.9000
[25] textshaping_0.3.6  purrr_1.0.1        vctrs_0.6.1        fs_1.6.1          
[29] curl_5.0.0         memoise_2.0.1      glue_1.6.2         cachem_1.0.7      
[33] evaluate_0.20      rmarkdown_2.21     compiler_4.2.3     pillar_1.9.0      
[37] desc_1.4.2         pkgconfig_2.0.3   

Activity

  1. hadley commented on May 7, 2023

    @hadley
    Member

    Thanks for filing this bug report! Unfortunately because there's no obvious fix and it affects so few people, we don't have the development resources to fix at this time. It's our policy to close such issues to help stay focussed on the biggest problems, but the issue is still indexed by google, so if other people hit it, they'll be able to find it, and we can consider reopen it if it turns out to be a common problem. Thanks for reporting and I'm sorry we couldn't help more 😞.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions