File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1999,7 +1999,7 @@ def __setstate__(self, state):
19991999
20002000 # re-initialise some of the unstored state information
20012001 self ._axobservers = []
2002- self . canvas = None
2002+ FigureCanvasBase ( self ) # Set self.canvas.
20032003 self ._layoutbox = None
20042004
20052005 if restore_to_pylab :
Original file line number Diff line number Diff line change 1010from matplotlib .dates import rrulewrapper
1111import matplotlib .pyplot as plt
1212import matplotlib .transforms as mtransforms
13+ import matplotlib .figure as mfigure
1314
1415
1516def test_simple ():
@@ -194,3 +195,13 @@ def test_shared():
194195@pytest .mark .parametrize ("cmap" , cm .cmap_d .values ())
195196def test_cmap (cmap ):
196197 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