R Scale plot elements within PDF of set width and height

前端 未结 4 374
刺人心
刺人心 2021-02-02 10:46

Though R plots sent to a PDF can be rescaled at will in an illustration or page layout software, scientific journals often insist that the plots provided have specific dimension

4条回答
  •  广开言路
    2021-02-02 11:35

    Journals insist on having specific plot dimensions in order to avoid scaling. If made, it can render the font size too small (or large) and inconsistent with the figure caption font size. That is why the plot elements (text, point size, etc.) by design have the same absolute size regardless of pdf size.

    You can change the default font size and point size, for example, with:

    p <- ggplot(iris, aes(x=Petal.Width, y=Petal.Length, colour=Species)) +
      geom_point(size=1.5) +  # default is 2
      theme_grey(base_size=10)  # default is 12
    ggsave("test.1.pdf", p)
    

    The defaults can be changed globally, too:

    update_geom_defaults("point", list(size=1.5))
    theme_set(theme_grey(base_size=10))
    

提交回复
热议问题