File tree 2 files changed +12
-1
lines changed 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -2026,7 +2026,7 @@ def __setstate__(self, state):
2026
2026
2027
2027
# re-initialise some of the unstored state information
2028
2028
self ._axobservers = []
2029
- self . canvas = None
2029
+ FigureCanvasBase ( self ) # Set self.canvas.
2030
2030
self ._layoutbox = None
2031
2031
2032
2032
if restore_to_pylab :
Original file line number Diff line number Diff line change 10
10
from matplotlib .dates import rrulewrapper
11
11
import matplotlib .pyplot as plt
12
12
import matplotlib .transforms as mtransforms
13
+ import matplotlib .figure as mfigure
13
14
14
15
15
16
def test_simple ():
@@ -194,3 +195,13 @@ def test_shared():
194
195
@pytest .mark .parametrize ("cmap" , cm .cmap_d .values ())
195
196
def test_cmap (cmap ):
196
197
pickle .dumps (cmap )
198
+
199
+
200
+ def test_unpickle_canvas ():
201
+ fig = mfigure .Figure ()
202
+ assert fig .canvas is not None
203
+ out = BytesIO ()
204
+ pickle .dump (fig , out )
205
+ out .seek (0 )
206
+ fig2 = pickle .load (out )
207
+ assert fig2 .canvas is not None
You can’t perform that action at this time.
0 commit comments