File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -2886,6 +2886,9 @@ def __getstate__(self):
28862886 # Set cached renderer to None -- it can't be pickled.
28872887 state ["_cachedRenderer" ] = None
28882888
2889+ # discard any changes to the dpi due to pixel ratio changes
2890+ state ["_dpi" ] = state .get ('_original_dpi' , state ['_dpi' ])
2891+
28892892 # add version information to the state
28902893 state ['__mpl_version__' ] = mpl .__version__
28912894
Original file line number Diff line number Diff line change 11from datetime import datetime
22import io
33from pathlib import Path
4+ import pickle
45import platform
56from threading import Timer
67from types import SimpleNamespace
@@ -1360,3 +1361,11 @@ def test_kwargs_pass():
13601361
13611362 assert fig .get_label () == 'whole Figure'
13621363 assert sub_fig .get_label () == 'sub figure'
1364+
1365+
1366+ def test_unpickle_with_device_pixel_ratio ():
1367+ fig = Figure (dpi = 42 )
1368+ fig .canvas ._set_device_pixel_ratio (7 )
1369+ assert fig .dpi == 42 * 7
1370+ fig2 = pickle .loads (pickle .dumps (fig ))
1371+ assert fig2 .dpi == 42
You can’t perform that action at this time.
0 commit comments