Commit b16411d
committed
Implement bbox_inches="tight" as a post-processing step.
The current implementation of bbox_inches="tight" is to no-output-draw
the figure, compute a tight bbox, and then shift all artists to their
"new" position in tight-bbox-coordinates, draw, and shift back -- which
causes all kinds of grief.
Instead, we can perform the real draw the first time, and then crop the
resulting image (either actually crop it for raster backends, or just
adjust the viewport for vector ones).
This PR is a proof-of-concept for such an approach (tests fail, that's
expected). Currently it writes the first file to the filesystem and
then edits it; likely the first file should be just kept in memory
instead (after all the final output could also just be an im-memory
buffer). This would also avoid having to dupe the metadata handling
(for agg).
Perhaps the method should be on the renderer instead (the exact API is
needs to be discussed). Extra points if the API is designed in such a
way that mplcairo can directly call into it.
Currently not implemented for postscript because bbox_inches="tight"
doesn't work there anyways (although we should fix it for postscript).
Not sure about pgf output, but that's probably workable...
Final version should keep some backcompat layer, not present here to
improve readability.1 parent 2e00dc0 commit b16411d
4 files changed
Lines changed: 57 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2274 | 2274 | | |
2275 | 2275 | | |
2276 | 2276 | | |
2277 | | - | |
2278 | | - | |
2279 | | - | |
2280 | | - | |
2281 | | - | |
| 2277 | + | |
2282 | 2278 | | |
2283 | 2279 | | |
2284 | 2280 | | |
| |||
2293 | 2289 | | |
2294 | 2290 | | |
2295 | 2291 | | |
2296 | | - | |
2297 | | - | |
2298 | | - | |
2299 | | - | |
2300 | | - | |
2301 | | - | |
2302 | | - | |
2303 | | - | |
2304 | | - | |
2305 | | - | |
2306 | | - | |
2307 | | - | |
2308 | | - | |
2309 | | - | |
2310 | | - | |
2311 | | - | |
2312 | 2292 | | |
2313 | 2293 | | |
2314 | 2294 | | |
| |||
2321 | 2301 | | |
2322 | 2302 | | |
2323 | 2303 | | |
2324 | | - | |
2325 | 2304 | | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
2326 | 2316 | | |
2327 | | - | |
2328 | | - | |
2329 | | - | |
2330 | 2317 | | |
2331 | 2318 | | |
2332 | 2319 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
569 | 576 | | |
570 | 577 | | |
571 | 578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2737 | 2737 | | |
2738 | 2738 | | |
2739 | 2739 | | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
2740 | 2766 | | |
2741 | 2767 | | |
2742 | 2768 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
1347 | 1348 | | |
1348 | 1349 | | |
1349 | 1350 | | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
1350 | 1362 | | |
1351 | 1363 | | |
1352 | 1364 | | |
| |||
0 commit comments