Skip to content

Render unsized plots at the default figure size in notebook sessions - #1389

Open
seeM wants to merge 8 commits into
mainfrom
feature/default-plot-size
Open

Render unsized plots at the default figure size in notebook sessions#1389
seeM wants to merge 8 commits into
mainfrom
feature/default-plot-size

Conversation

@seeM

@seeM seeM commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Addresses posit-dev/positron#15260.

This PR is stacked on #1387.

Summary

When a notebook cell does not specify fig-width or fig-height, Ark currently sizes its plots to output_width_px with a 4:3 aspect ratio. This makes plots expand with the viewport and become especially large when the editor is wide or other panes are minimized.

This PR instead renders unsized plots at Quarto's default figure dimensions: 7 × 5 inches. This matches quarto render and is analogous to the Python kernel falling back to Matplotlib's default figure size.

The same default applies when an execute request contains no Positron metadata, including requests from standard Jupyter frontends. At Ark's platform-default DPI, the resulting logical dimensions are:

  • macOS at 96 DPI: 672 × 480 pixels;
  • Linux and Windows at 72 DPI: 504 × 360 pixels.

output_width_px remains part of the protocol but no longer affects plot sizing.

Additional changes

  • output_pixel_ratio is applied independently of figure dimensions, so unsized plots remain sharp on HiDPI displays.
  • When a later execution updates an existing plot, its stored intrinsic size is refreshed using that execution's figure dimensions. This matches knitr, where a chunk's figure options apply to plots it modifies.
  • Sizing resolution is consolidated in a new PlotSizing type in plots/sizing.rs.
  • Width and height resolve independently using this precedence:
    1. ark.plot.width or ark.plot.height;
    2. the requested fig-width or fig-height;
    3. the default figure dimension.

Screenshots

Before and after: unsized plot in a wide Quarto editor

Explicit figure dimensions remain supported

Unsized plots remain sharp on HiDPI displays

QA

With inline output enabled in a Quarto document:

  1. Run plot(1:10) without cell options. It should render at 7 × 5 inches regardless of the editor width.
  2. Add fig-width and fig-height. The plot should use those dimensions.
  3. Set ark.plot.width or ark.plot.height. Each R option should override the corresponding cell option.
  4. On a HiDPI display, verify that an unsized plot remains sharp without being displayed at an enlarged size.

@seeM
seeM force-pushed the feature/default-plot-size branch from 4046cac to 4d3e3a2 Compare August 4, 2026 08:39
Base automatically changed from feature/hidpi-plot-metadata to main August 4, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant