8000 Backport PR #20931: API: rename draw_no_output to draw_without_rendering · meeseeksmachine/matplotlib@3b2484c · GitHub
[go: up one dir, main page]

Skip to content

Commit 3b2484c

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR matplotlib#20931: API: rename draw_no_output to draw_without_rendering
1 parent 770f1b2 commit 3b2484c

15 files changed

+52
-50
lines changed

doc/users/next_whats_new/fig_draw_no_output.rst

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Figure now has ``draw_without_rendering`` method
2+
------------------------------------------------
3+
4+
Some aspects of a figure are only determined at draw-time, such as the exact
5+
position of text artists or deferred computation like automatic data limits.
6+
If you need these values, you can use ``figure.canvas.draw()`` to force a full
7+
draw. However, this has side effects, sometimes requires an open file, and is
8+
doing more work than is needed.
9+
10+
The new `.Figure.draw_without_rendering` method runs all the updates that
11+
``draw()`` does, but skips rendering the figure. It's thus more efficient if you
12+
need the updated values to configure further aspects of the figure.

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ def _draw(renderer): raise Done(renderer)
15701570
def _no_output_draw(figure):
15711571
# _no_output_draw was promoted to the figure level, but
15721572
# keep this here in case someone was calling it...
1573-
figure.draw_no_output()
1573+
figure.draw_without_rendering()
15741574

15751575

15761576
def _is_non_interactive_terminal_ipython(ip):

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2793,7 +2793,7 @@ def print_pdf(self, filename, *,
27932793
file.close()
27942794

27952795
def draw(self):
2796-
self.figure.draw_no_output()
2796+
self.figure.draw_without_rendering()
27972797
return super().draw()
27982798

27992799

lib/matplotlib/backends/backend_pgf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ def get_renderer(self):
883883
return RendererPgf(self.figure, None)
884884

885885
def draw(self):
886-
self.figure.draw_no_output()
886+
self.figure.draw_without_rendering()
887887
return super().draw()
888888

889889

lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ def _print_figure_tex(
11191119
_move_path_to_path_or_stream(tmpfile, outfile)
11201120

11211121
def draw(self):
1122-
self.figure.draw_no_output()
1122+
self.figure.draw_without_rendering()
11231123
return super().draw()
11241124

11251125

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ def get_default_filetype(self):
13431343
return 'svg'
13441344

13451345
def draw(self):
1346-
self.figure.draw_no_output()
1346+
self.figure.draw_without_rendering()
13471347
return super().draw()
13481348

13491349

lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ def draw(self, renderer):
28082808

28092809
self.canvas.draw_event(renderer)
28102810

2811-
def draw_no_output(self):
2811+
def draw_without_rendering(self):
28122812
"""
28132813
Draw the figure with no output. Useful to get the final size of
28142814
artists that require a draw before their size is known (e.g. text).

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4793,7 +4793,7 @@ def test_reset_ticks(fig_test, fig_ref):
47934793
labelsize=14, labelcolor='C1', labelrotation=45,
47944794
grid_color='C2', grid_alpha=0.8, grid_linewidth=3,
47954795
grid_linestyle='--')
4796-
fig.draw_no_output()
4796+
fig.draw_without_rendering()
47974797

47984798
# After we've changed any setting on ticks, reset_ticks will mean
47994799
# re-creating them from scratch. This *should* appear the same as not

lib/matplotlib/tests/test_colorbar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def test_mappable_2d_alpha():
613613
# the original alpha array
614614
assert cb.alpha is None
615615
assert pc.get_alpha() is x
616-
fig.draw_no_output()
616+
fig.draw_without_rendering()
617617

618618

619619
def test_colorbar_label():
@@ -766,7 +766,7 @@ def test_inset_colorbar_layout():
766766
cax = ax.inset_axes([1.02, 0.1, 0.03, 0.8])
767767
cb = fig.colorbar(pc, cax=cax)
768768

769-
fig.draw_no_output()
769+
fig.draw_without_rendering()
770770
# make sure this is in the figure. In the colorbar swapping
771771
# it was being dropped from the list of children...
772772
np.testing.assert_allclose(cb.ax.get_position().bounds,
@@ -806,7 +806,7 @@ def test_aspects():
806806
pc = ax[mm, nn].pcolormesh(np.arange(100).reshape(10, 10))
807807
cb[nn][mm] = fig.colorbar(pc, ax=ax[mm, nn], orientation=orient,
808808
aspect=aspect, extend=extend)
809-
fig.draw_no_output()
809+
fig.draw_without_rendering()
810810
# check the extends are right ratio:
811811
np.testing.assert_almost_equal(cb[0][1].ax.get_position().height,
812812
cb[0][0].ax.get_position().height * 0.9,

0 commit comments

Comments
 (0)
0