Commit b9cea08
committed
Don't fallback to agg in tight_layout.get_renderer.
tight_layout.get_renderer currently falls back to agg if it is unable to
get a renderer for the current canvas, but we actually have a way to
coerce the canvas to produce a renderer, via
backend_bases._get_renderer.
This renderer gets used by the tight_layout machinery to estimate text
size. Falling back to Agg would produce bad results in the (admittedly
rare) cases where text size estimation yields very different results
depending on the renderer -- the easiest way to trigger this is to use
a "thin" font, e.g. Tex Gyre Chorus, while using the pdf backend with
the "pdf.use14corefonts" rcParam set to True, which effectively forces
Helvetica. e.g.
```
from pylab import *
matplotlib.use("pdf")
rcdefaults()
rcParams.update({"pdf.use14corefonts": True, "font.family": "TeX Gyre Chorus"})
plot()
margins(0)
tight_layout(0)
savefig("/tmp/test.pdf")
```
would crop the tick labels before this PR.
(The real point is not to fix an obscure edge case, but actually to have
fewer places that fall back to Agg as "favorited" backend.)1 parent 49593b7 commit b9cea08
3 files changed
Lines changed: 26 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1501 | 1501 | | |
1502 | 1502 | | |
1503 | 1503 | | |
1504 | | - | |
| 1504 | + | |
1505 | 1505 | | |
1506 | 1506 | | |
1507 | 1507 | | |
| |||
1520 | 1520 | | |
1521 | 1521 | | |
1522 | 1522 | | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
1523 | 1526 | | |
1524 | | - | |
| 1527 | + | |
1525 | 1528 | | |
1526 | 1529 | | |
1527 | 1530 | | |
| |||
2089 | 2092 | | |
2090 | 2093 | | |
2091 | 2094 | | |
2092 | | - | |
| 2095 | + | |
2093 | 2096 | | |
2094 | 2097 | | |
2095 | 2098 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | 172 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
182 | 177 | | |
183 | 178 | | |
184 | 179 | | |
| |||
0 commit comments