Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22e84f6

Browse files
committed
DOC: add notes to reference draw methods
The full artist tree needs to be walked in `draw` to ensure that deferred work is done.
1 parent 1173770 commit 22e84f6

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,14 @@ def release_mouse(self, ax):
20302030
self.mouse_grabber = None
20312031

20322032
def draw(self, *args, **kwargs):
2033-
"""Render the `.Figure`."""
2033+
"""
2034+
Render the `.Figure`.
2035+
2036+
It is important that this method actually walk the artist tree
2037+
even if not output is produced because this will trigger
2038+
deferred work (like computing limits auto-limits and tick
2039+
values) that users may want access to before saving to disk.
2040+
"""
20342041

20352042
def draw_idle(self, *args, **kwargs):
20362043
"""

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,6 +2734,7 @@ def draw(self):
27342734
_no_output_draw(self.figure)
27352735
return super().draw()
27362736

2737+
27372738
FigureManagerPdf = FigureManagerBase
27382739

27392740

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,7 @@ def draw(self):
13671367
_no_output_draw(self.figure)
13681368
return super().draw()
13691369

1370+
13701371
FigureManagerSVG = FigureManagerBase
13711372

13721373

lib/matplotlib/backends/backend_template.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,14 @@ class methods button_press_event, button_release_event,
191191
"""
192192

193193
def draw(self):
194-
"""Draw the figure using the renderer."""
194+
"""
195+
Draw the figure using the renderer.
196+
197+
It is important that this method actually walk the artist tree
198+
even if not output is produced because this will trigger
199+
deferred work (like computing limits auto-limits and tick
200+
values) that users may want access to before saving to disk.
201+
"""
195202
renderer = RendererTemplate(self.figure.dpi)
196203
self.figure.draw(renderer)
197204

0 commit comments

Comments
 (0)