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

BiocStyle::html_document doesn't completely respect mfrow #65

Open
LTLA opened this issue Jul 9, 2019 · 2 comments
Open

BiocStyle::html_document doesn't completely respect mfrow #65

LTLA opened this issue Jul 9, 2019 · 2 comments

Comments

@LTLA
Copy link
Contributor

LTLA commented Jul 9, 2019

Consider the following:

---
title: Test
author: Aaron Lun
output:
  html_document
---

asdas

```{r, fig.wide=TRUE, fig.asp=1/3}
par(mfrow=c(1,3), mar=c(5.1, 4.1, 4.1, 2.1))
for (i in 1:10) {
    plot(1,i)
}
```

When this is rmarkdown::render()d, all is well, with the last plot occupying one third of the width:

image

However, if we change html_document to BiocStyle::html_document, we get instead:

image

In short, the last plot is inflated to occupy the entire screen; this is pretty ugly.

Session information
R version 3.6.0 Patched (2019-05-10 r76483)
Platform: x86_64-apple-darwin17.7.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS:   /Users/luna/Software/R/R-3-6-branch-dev/lib/libRblas.dylib
LAPACK: /Users/luna/Software/R/R-3-6-branch-dev/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] BiocStyle_2.13.2

loaded via a namespace (and not attached):
 [1] BiocManager_1.30.4 compiler_3.6.0     bookdown_0.11      magrittr_1.5
 [5] tools_3.6.0        htmltools_0.3.6    yaml_2.2.0         Rcpp_1.0.1
 [9] stringi_1.4.3      rmarkdown_1.13     knitr_1.23         stringr_1.4.0
[13] xfun_0.8           digest_0.6.20      evaluate_0.14
@grimbough
Copy link
Collaborator

This behaviour is because BiocStyle automatically crops images, so the two columns of white space are removed. Perhaps it shouldn't do that if par() has been changed from the default values?

You can stop the behaviour by setting crop = NULL in the code chunk options e.g.

```{r, fig.wide=TRUE, fig.asp=1/3, crop=NULL}
par(mfrow=c(1,3), mar=c(5.1, 4.1, 4.1, 2.1))
for (i in 1:10) {
    plot(1,i)
}
```

gets me

@LTLA
Copy link
Contributor Author

LTLA commented Nov 12, 2019

Thanks, it wasn't obvious that crop=FALSE was an option. This seems like a divergence from knitr defaults, so perhaps that should be mentioned somewhere in the documentation; certainly it would eliminate questions like this one.

lcolladotor added a commit to leekgroup/regionReport that referenced this issue Apr 24, 2020
…ound taken

This is also an opportunity to link to the relevant GitHub issues and Bioc-devel
threads.

Cropping images through `magick::image_trim()` as done by default by
`BiocStyle::html_document()` can fail on Linux. This could be an ImageMagick
issue or an issue about lack of resources. The full investigative report is at
https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016650.html.
This is related to:
yihui/knitr#1785 (comment)
yihui/knitr#1796
Bioconductor/BiocStyle#65 (comment)
ropensci/magick#171
ropensci/magick#194
In regionReport version 1.21.10 I have opted by using `crop = NULL` to disable
cropping of images by `BiocStyle::html_document()` and thus avoid the
issues with `ImageMagick` either coming from `magick`, from the version of
`ImageMagick` installed on the Linux Bioconductor build machine and devel
docker, or from resources in these two Linux environments as described in the
investigative report.
About a month ago I also saw failures on Windows on Bioc 3.10. Whether they were
caused by ggbio 1.35.1 or this issue will remain a mystery. But it's likely
that this `magick::image_trim()` issue also affected the Bioconductor windows
builder.
The related bioc-devel threads are:
https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016538.html
https://stat.ethz.ch/pipermail/bioc-devel/2020-March/016365.html
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