When the following code is run interactively with the RStudio IDE, the font size does not scale with the resolution. In other words, the font "shrinks" at 300 dpi. However, if this code is sourced the font size appears to scale appropriately with the resolution.
Is this a bug or am I doing something wrong?
library(tidyverse)
figure01 = ggplot(iris) +
geom_boxplot(aes(x = Species, y = Petal.Length)) +
scale_x_discrete("Species") +
scale_y_continuous("Petal length (mm)")
# Resolution is 300
ggsave(filename = "figure01_300.png", plot = figure01,
width = 80, height = 80, dpi = 300, units = "mm")
# Resolution is 96
ggsave(filename = "figure01_96.png", plot = figure01,
width = 80, height = 80, dpi = 96, units = "mm")
I am using Version 1.4.1106 for x86_64-pc-linux-gnu.
R version 4.0.3, tidyverse version 1.3.0
2021/3/7 Update: Apparently there is no problem when running RStudio in Windows 10.
2021/3/8 Update: The problem I observed on Linux was resolved, because the behavior disappeared.