Rmarkdown/Rnotebook text in graphs too small, lines to thin after update

After updating Rstudio and R, graphs in Rmarkdown/Rnotebook are getting generated with text that is too small and lines that are too thin. This is true both in the editor and in the generated html files.

This is NOT an issue of the fig.width and fig.height. Changing those increases the overall size of the graph (as usual) but does not effect the size of the text in the graph or the line thickness.

It appears that the graphs are being 'scaled' somehow. Does anyone know how to control this? I've tried setting output.height and output.width but this has no effect.


PS forgot to specify versions, etc.:

  • RStudio 2021.09.1 Build 372
  • R version 4.1.1 (2021-08-10) -- "Kick Things"
  • OS: Debian GNU/Linux 11 (bullseye)
  • Rmarkdown setup:

title: xxx
toc: yes
chunk_output_type: inline

knitr::opts_chunk$set(comment="",results = "hide",echo=FALSE, fig.width=12, fig.height=8,

With which plots this is happening ? Do you use default graphic device ?

There are other option that you can change like dpi or fig.retinaif you want to customize the figure. These two can impact the thin vs thick impression.

Otherwise, I don't really know how to help as I can't reproduce

I am using the default graphics device. I've tried changing dpi and fig.retina. Neither have any effect.

However, decreasing fig.width and fig.height seems to help. I had been using fig.width=12, fig.height=8 (for years), e.g.

knitr::opts_chunk$set(comment="",results = "hide",echo=FALSE, fig.width=12, fig.height=8,

Switching to

knitr::opts_chunk$set(comment="",results = "hide",echo=FALSE,fig.width=9, fig.height=6,

has restored graphs to something like what I had prior to upgrading.

Something related to scaling must have changed but I can't figure out what. At least my graphs are legible again, but I'd still like to know what changed.

I don't remember us changing something in the tools. Maybe the IDE changed something I don't know.

As I said, dpiand fig.retina come into play regarding scaling of final figure.

Glad you found a compromise.

Can some one explain the difference between dpi and fig.retina? Doesfig.retina only effect retina monitors (seems unlikely)? Or is it just an alt way of specifying dpi? Or is is OS-X specific? (I run Rstudio under linux, not OS-X.)


From documentation Options - Chunk options and package options - Yihui Xie | 谢益辉

  • fig.retina : ( 1 ; numeric) This option only applies to HTML output. For Retina displays, setting this option to a ratio (usually 2) will change the chunk option dpi to dpi * fig.retina , and out.width to fig.width * dpi / fig.retina internally. For example, the physical size of an image is doubled, and its display size is halved when fig.retina = 2 .

I believe it will be apply as default is set to 2 in rmarkdown::html_document, but you can change it to 1 if you want to disable it to see the difference.

If you think there is something not right in that, you can open an issue in knitr so that we have insight to possibly revisit or document better the calculations.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.