Skip to content

Commit 1784c73

Browse files
committed
Add docs to state that you should not keep a reference to the canvas
1 parent 0e078a7 commit 1784c73

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

doc/users/next_whats_new/pyplot-register-figure.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,8 @@ the current canvas to save the figure (if possible). Since `.FigureCanvasBase`
5151
is Agg-based any Agg-based backend will create the same file output. There may
5252
be slight differences for non-Agg backends; e.g. if you use "GTK4Cairo" as
5353
interactive backend, ``fig.savefig("file.png")`` may create a slightly different
54-
image depending on whether the figure is registered with pyplot or not.
54+
image depending on whether the figure is registered with pyplot or not. In
55+
general, you should not store a reference to the canvas, but rather always
56+
obtain it from the figure with ``fig.canvas``. This will return the current
57+
canvas, which is either the original `.FigureCanvasBase` or a backend-dependent
58+
subclass, depending on whether the figure is registered with pyplot or not.

0 commit comments

Comments
 (0)