Skip to content

Set out-width equal to fig-width for figure created in code block #4933

@see24

Description

@see24

Bug description

I would like the out-width to equal the fig-width that I have specified in inches in a code chunk. In the documentation it says "By default figures are displayed using their actual size" but this does not happen when I have set the dpi of my figure to be larger than the default. I would like the out-width to be equal to the fig-width in terms of the actual space it takes up on my screen rather than the current behaviour where it is much larger if I have set a larger than default dpi. Currently I can only get this outcome by setting all 4 of fig-width, fig-height, out-width and out-height. If the default needs to stay the same could there be a way to set a yaml option that ties out-width to fig-width?

---
title: "Dpi in Yaml"
format: html
fig-dpi: 300
---

## no options

The figure is created with a size that fits the output space.

```{r}
plot(mtcars[1:4])
```

## fig-height and fig-width specified

If fig-height and fig-width are small relative to the output space the figure will be expanded to fill it. Eg the font size is too large.

```{r}
#| fig-width: 3
#| fig-height: 3
plot(mtcars[1:4])
```

## out-height and out-width specified

Only by setting all 4 can I get a figure that is displayed as the size created it with. Despite this statement in quarto docs "[By default figures are displayed using their actual size](https://quarto.org/docs/authoring/figures.html#figure-sizing)"

```{r}
#| fig-width: 3
#| fig-height: 3
#| out-width: 3in
#| out-height: 3in
plot(mtcars[1:4])
```

RStudio version 2023.03.0+386
Windows 10
Checking Quarto installation......OK
Version: 1.2.335
Path: C:\Program Files\RStudio\resources\app\bin\quarto\bin
CodePage: 1252

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
  • Please provide the output of quarto check so we know which version of quarto and its dependencies you're running.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions