Skip to content

PR: Add handler to update matplotlib inline backend figure format #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion spyder_kernels/console/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def __init__(self, *args, **kwargs):
'set_sympy_forecolor': self.set_sympy_forecolor,
'set_pdb_echo_code': self.set_pdb_echo_code,
'update_syspath': self.update_syspath,
'is_special_kernel_valid': self.is_special_kernel_valid
'is_special_kernel_valid': self.is_special_kernel_valid,
'set_inline_backend_figure_format':
self.set_inline_backend_figure_format
}
for call_id in handlers:
self.frontend_comm.register_call_handler(
Expand Down Expand Up @@ -409,6 +411,17 @@ def is_special_kernel_valid(self):
return u'cython'
return None

def set_inline_backend_figure_format(self, figure_format):
"""Set matplolib inline backend figure format."""
from IPython.core.getipython import get_ipython
try:
get_ipython().run_line_magic(
'config',
"InlineBackend.figure_format = '{figure_format}'".format(
figure_format=figure_format))
except Exception:
pass

# -- Private API ---------------------------------------------------
# --- For the Variable Explorer
def _get_current_namespace(self, with_magics=False):
Expand Down
3 changes: 2 additions & 1 deletion spyder_kernels/console/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ def kernel_config():
# Figure format
format_o = os.environ.get('SPY_FORMAT_O')
formats = {'0': 'png',
'1': 'svg'}
'1': 'svg',
'2': 'retina'}
if format_o is not None:
spy_cfg.InlineBackend.figure_format = formats[format_o]

Expand Down