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

plot incorrectly cropped when setting legend font face #75

Open
grlloyd opened this issue Apr 23, 2020 · 2 comments
Open

plot incorrectly cropped when setting legend font face #75

grlloyd opened this issue Apr 23, 2020 · 2 comments

Comments

@grlloyd
Copy link

grlloyd commented Apr 23, 2020

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
```{r solo-plot-italic}
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
```{r solo-plot-plain}
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
```{r cowplot-italic}
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
```{r cowplot-plain}
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
Copy link
Author

grlloyd commented Apr 24, 2020

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

@lshep
Copy link

lshep commented Apr 27, 2020

Also for reference. This conversation on bioc devel: https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016656.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