Commit 35d4a17
authored
Size plots appropriately in R notebooks and Quarto inline output (#12539)
This change adds metadata to execution requests so that it is possible
for kernels to size plots to fit the viewport/DPI.
For Quarto, we add cell options (such as `fig-width` and `fig-height`)
to the execution metadata; for both Quarto inline outputs and Jupyter
editors, we add the width of the output field and the device pixel ratio
to the execution request.
In notebooks, this means that your plots render crisply on Retina
displays and are sized appropriately to your viewport:
<img width="768" height="831" alt="image"
src="https://github.com/user-attachments/assets/d2a5ac46-afb3-4a88-9b79-deab6d842b41"
/>
In Quarto inline outputs, this means that figure width/height are
respected, too, so you get a preview with the correct aspect ratio:
<img width="758" height="363" alt="image"
src="https://github.com/user-attachments/assets/98a1505a-8620-43b0-ba0a-bec65ec01daa"
/>
Requires posit-dev/ark#1119
Requires posit-dev/qa-example-content#116
Related to quarto-dev/quarto#938
Addresses #8104
Addresses #12150
### Release Notes
<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
The note will automatically be tagged with the language.
These notes are typically filled by the Positron team. If you are an
external
contributor, you may ignore this section.
-->
#### New Features
- Quarto inline output for R now respects `fig-width` and `fig-height`
options (#12150)
#### Bug Fixes
- Plots in R notebooks are now sized correctly (#8104)
### QA Notes
This PR doesn't attempt to size Python plots, though it takes the first
step towards doing so by adding the right metadata. I added a hidden
magic you can use to see what is being sent to Python:
```python
%_positron_exec_metadata
```
The Ark equivalent is `.ps.internal(active_request())`.
It also doesn't apply to the Plots pane, just notebook-style execution.
We'll need to wait for a new Quarto extension to do that
(quarto-dev/quarto#938).
Test tags: `@:quarto` `@positron-notebooks` `@notebooks`1 parent f234e05 commit 35d4a17
File tree
14 files changed
+486
-13
lines changed- extensions
- positron-python/python_files/posit/positron
- positron-r
- src/vs/workbench/contrib
- notebook/test/browser
- positronNotebook/browser
- notebookCells
- positronQuarto
- browser
- common
- test/common
- runtimeNotebookKernel
- browser
- tests/browser
- test/e2e/tests
- notebooks-positron
- notebook
- quarto
14 files changed
+486
-13
lines changedLines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
225 | 236 | | |
226 | 237 | | |
227 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1094 | 1094 | | |
1095 | 1095 | | |
1096 | 1096 | | |
1097 | | - | |
| 1097 | + | |
1098 | 1098 | | |
1099 | 1099 | | |
1100 | 1100 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
21 | 33 | | |
22 | 34 | | |
23 | 35 | | |
| |||
439 | 451 | | |
440 | 452 | | |
441 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
442 | 461 | | |
443 | 462 | | |
444 | 463 | | |
| |||
Lines changed: 66 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
655 | 720 | | |
656 | 721 | | |
657 | 722 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
99 | 106 | | |
100 | 107 | | |
Lines changed: 42 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
327 | 330 | | |
328 | 331 | | |
329 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
330 | 336 | | |
331 | 337 | | |
332 | 338 | | |
| |||
373 | 379 | | |
374 | 380 | | |
375 | 381 | | |
376 | | - | |
| 382 | + | |
377 | 383 | | |
378 | 384 | | |
379 | 385 | | |
| |||
386 | 392 | | |
387 | 393 | | |
388 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
389 | 403 | | |
390 | 404 | | |
391 | 405 | | |
392 | 406 | | |
393 | 407 | | |
394 | | - | |
| 408 | + | |
395 | 409 | | |
396 | 410 | | |
397 | 411 | | |
| |||
1646 | 1660 | | |
1647 | 1661 | | |
1648 | 1662 | | |
1649 | | - | |
| 1663 | + | |
1650 | 1664 | | |
1651 | 1665 | | |
1652 | 1666 | | |
| |||
1663 | 1677 | | |
1664 | 1678 | | |
1665 | 1679 | | |
1666 | | - | |
1667 | | - | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
1668 | 1688 | | |
1669 | 1689 | | |
1670 | 1690 | | |
| |||
2036 | 2056 | | |
2037 | 2057 | | |
2038 | 2058 | | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
2039 | 2076 | | |
2040 | 2077 | | |
2041 | 2078 | | |
| |||
Lines changed: 37 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
60 | 87 | | |
61 | 88 | | |
62 | 89 | | |
| |||
75 | 102 | | |
76 | 103 | | |
77 | 104 | | |
78 | | - | |
| 105 | + | |
79 | 106 | | |
80 | 107 | | |
81 | 108 | | |
| |||
93 | 120 | | |
94 | 121 | | |
95 | 122 | | |
| 123 | + | |
96 | 124 | | |
97 | 125 | | |
98 | 126 | | |
| |||
112 | 140 | | |
113 | 141 | | |
114 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
115 | 148 | | |
116 | 149 | | |
117 | 150 | | |
118 | 151 | | |
119 | | - | |
| 152 | + | |
120 | 153 | | |
121 | 154 | | |
122 | 155 | | |
| |||
127 | 160 | | |
128 | 161 | | |
129 | 162 | | |
130 | | - | |
| 163 | + | |
131 | 164 | | |
132 | 165 | | |
133 | 166 | | |
| |||
0 commit comments