Skip to content

Plot Compositions don't render in Quarto with knitr #970

Closed

Description

@jmclawson

The new plot composition options are really exciting, but they don't work when the engine is set to knitr. (This issue might instead belong to Quarto or knitr.)

---
title: "Plot composition in Quarto"
engine: knitr
---

```{python}
from plotnine import ggplot, aes, geom_point, geom_bar
from plotnine.data import diamonds

p1 = (
  ggplot(
    data = diamonds,
    mapping = aes(x = "carat", y = "price"))
  + geom_point()
)

p2 = (
  ggplot(
    data = diamonds,
    mapping = aes(x = "cut"))
  + geom_bar()
)
```

Individual plots can be shown with `.show()`:

```{python}
p1.show()
```

Combined plots don't have a `.show()` method.

```{python}
combined = p1 / p2

combined
```

When rendered, the last code chunk yields this as output:
Stack(items=[<plotnine.ggplot.ggplot object at 0x108f3eb10>, <plotnine.ggplot.ggplot object at 0x10d893ac0>])

Activity

  1. added a commit that references this issue on Aug 28, 2025
    f57645e
  2. has2k1 commented on Aug 28, 2025

    @has2k1
    Owner

    Resolving this as part of #969, and when the plots are the last they should be shown automatically.

  3. jmclawson commented on Aug 28, 2025

    @jmclawson
    Author

    Thanks, on both counts. I look forward to trying it out!

  4. added a commit that references this issue on Aug 28, 2025
    2fc174d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions