I have an Rmd file (see below). When I knit it in RStudio Server, the plot label fonts look awful, like this:
If I knit it from the command line or from RStudio (desktop app), it works fine.
When knitting from RStudio Server I see the following warning which I suspect is part of the problem:
In grDevices::png(f) : unable to open connection to X11 display ''
Here is the .Rmd file:
---
title: "test plotting"
author: "Janet Young"
output:
html_document:
toc: true
toc_float:
collapsed: false
number_sections: true
code_folding: hide
---
```{r setup, include=FALSE, echo=FALSE}
library(ggplot2)
library(knitr)
library(Cairo)
options(bitmapType="cairo")
```
```{r simple plot1, fig.height=4, fig.width=7}
dat <- data.frame(samples=paste("sample",rep(1:10, 100), sep=""), count=rnorm(1000,1))
ggplot(dat, aes(samples)) +
geom_bar() +
labs(title="total number of rows, all samples",
x="", y = "number of rows") +
theme(axis.text.x=element_text(angle = 90, hjust=1, vjust=0.5))
```
```{r simple plot2, fig.height=4, fig.width=7}
plot(1:10,1:10, xlab="my x axis", ylab="my y axis")
```
```{r show dpi}
dpi <- knitr::opts_chunk$get()$dpi
cat("opts_chunk dpi is",dpi,"\n")
```