Skip to content

Specifying dpi option in theme does not work in quarto #773

@machow

Description

@machow

When using quarto with a qmd, setting the theme(dpi=...) option does not seem to affect plot output.

example.qmd

---
format:
    html:
       # setting fig-dpi does affect DPI
       # fig-dpi: 400
       fig-dpi: 100
---

```{python}
from plotnine import *
import pandas as pd

df = pd.DataFrame({"x": [1,2,3], "y": [4,5,6]})
```

```{python}
ggplot(df, aes("x", "y")) + geom_point()
```

```{python}
ggplot(df, aes("x", "y")) + geom_point() + theme(figure_size=(6, 4), dpi = 400)
```

Both plots produced for me are around 8kb, and about 600 x 400px. Note that leaving out the fig-dpi option completely in the top-matter results in a DPI setting of 100 (or similar) in the rcParams.

Possible causes

Pieces I noticed digging around:

  • quarto sets a number of matplotlib settings before running python qmds
  • uncommenting the fig-dpi in the yaml topmatter of the example will affect plots. (and it's set via code in point above).
  • when run in a jupyterlab notebook, setting theme(dpi=...) worked fine

cc @cscheid, in case there's another important quarto piece I'm missing?! I'm a bit stumped here 😓

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions