Bioconductor / BiocStyle

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

plot incorrectly cropped when setting legend font face #75

Open grlloyd opened 4 years ago

grlloyd commented 4 years ago

When I set the legend font face in a ggplot2 theme to "bold" or "italic" the legend is excluded from the rendered image in the pdf. When using grid plots (e.g. with cowplot package) any plot after the first isn't rendered.

In the example below plots with italic font are rendered incorrectly in the pdf.


---
title: "title"
output: BiocStyle::pdf_document
---

```{r}
library(ggplot2)
library(cowplot)

# iris data
A = iris

solo plot, italic font

g1 = ggplot(data=A,aes(x=Sepal.Length,y=Sepal.Width,colour=Species)) +
    geom_point() + theme(legend.title = element_text(face='italic'))

plot(g1)

solo plot, plain font

g2 = g1=ggplot(data=A,aes(x=Sepal.Length,y=Sepal.Width,colour=Species)) +
    geom_point() + theme(legend.title = element_text(face='plain'))

plot(g2)

grid plot, italic font

g1 = ggplot(data=A,aes(x=Sepal.Length,y=Sepal.Width,colour=Species)) +
    geom_point() + theme(legend.title = element_text(face='italic'))

plot_grid(g1,g1,nrow=1)

grid plot, plain font

g2 = ggplot(data=A,aes(x=Sepal.Length,y=Sepal.Width,colour=Species)) +
        geom_point() + theme(legend.title = element_text(face='plain'))

plot_grid(g2,g2,nrow=1)
grlloyd commented 4 years ago

Setting knitr::opts_chunk$set(crop = NULL) fixes this. This means that the figures are not being cropped as intended by BiocStyle though.

lshep commented 4 years ago

Also for reference. This conversation on bioc devel: https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016656.html