Bioconductor / BiocStyle

Issues and pull requests for BiocStyle should go here.
12 stars 20 forks source link

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

Open LTLA opened 5 years ago

LTLA commented 5 years ago

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](https://user-images.githubusercontent.com/8166669/60925273-0f5bb180-a258-11e9-82d2-19b74a2fa9d0.png)

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

![image](https://user-images.githubusercontent.com/8166669/60925314-2c908000-a258-11e9-82b8-8d46bf3e8ec4.png)

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

<details>
<summary>Session information</summary>

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


</details>
grimbough commented 5 years ago

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
<p align="center">
<img src="https://user-images.githubusercontent.com/971237/68663292-b0c47e00-053e-11ea-8c2a-bf54f550ac61.png" height=500></p>
LTLA commented 5 years ago

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.