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

Skip to content

Commit 2181f7e

Browse files
author
klaus
committed
optional user defined svg hash salt
1 parent 1fe4df7 commit 2181f7e

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

doc/users/whats_new/rcparams.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Added ``svg.hashsalt`` key to rcParams
2+
```````````````````````````````````````
3+
If ``svg.hashsalt`` is ``None`` (which it is by default), the svg backend uses ``uuid4`` to generate the hash salt.
4+
If it is not ``None``, it must be a string that is used as the hash salt instead of ``uuid4``.
5+
This allows for deterministic SVG output.

lib/matplotlib/backends/backend_svg.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ def _write_default_style(self):
308308

309309
def _make_id(self, type, content):
310310
content = str(content)
311-
salt = str(uuid.uuid4())
311+
if rcParams['svg.hashsalt'] is None:
312+
salt = str(uuid.uuid4())
313+
else:
314+
salt = rcParams['svg.hashsalt']
312315
if six.PY3:
313316
content = content.encode('utf8')
314317
salt = salt.encode('utf8')

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@ def validate_hist_bins(s):
11651165
# True to save all characters as paths in the SVG
11661166
'svg.embed_char_paths': [True, deprecate_svg_embed_char_paths],
11671167
'svg.fonttype': ['path', validate_svg_fonttype],
1168+
'svg.hashsalt': [None, validate_any],
11681169

11691170
# set this when you want to generate hardcopy docstring
11701171
'docstring.hardcopy': [False, validate_bool],

0 commit comments

Comments
 (0)