Skip to content

Commit

Permalink
add regex filter to remove illegal filename characters from matplotli…
Browse files Browse the repository at this point in the history
…b window_title
  • Loading branch information
jat255 committed Mar 26, 2018
1 parent 692ee69 commit 9b39cb2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hyperspy/drawing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import hyperspy as hs
from distutils.version import LooseVersion
import logging
import re

from hyperspy.defaults_parser import preferences

Expand Down Expand Up @@ -125,6 +126,8 @@ def create_figure(window_title=None,
"""
fig = plt.figure(**kwargs)
if window_title is not None:
# remove non-alphanumeric characters to prevent file saving problems
window_title = re.sub('[^\w\-_\. ]', '_', window_title)
fig.canvas.set_window_title(window_title)
if _on_figure_window_close is not None:
on_figure_window_close(fig, _on_figure_window_close)
Expand Down

0 comments on commit 9b39cb2

Please sign in to comment.