Skip to content

Commit

Permalink
Merge from 3.x: PR #4361
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Apr 14, 2017
2 parents 98a2d04 + d58c110 commit 9ba55e9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion spyder/plugins/tests/test_ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_mpl_backend_change(ipyconsole, qtbot):
with qtbot.waitSignal(shell.executed):
shell.execute('import matplotlib.pyplot as plt')

# Generate an inline plot
# Generate a plot
with qtbot.waitSignal(shell.executed):
shell.execute('plt.plot(range(10))')

Expand Down
48 changes: 26 additions & 22 deletions spyder/utils/ipython/start_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,32 @@ def kernel_config():

# Inline backend configuration
if mpl_backend == 'inline':
# Figure format
format_o = CONF.get('ipython_console',
'pylab/inline/figure_format', 0)
formats = {0: 'png', 1: 'svg'}
spy_cfg.InlineBackend.figure_format = formats[format_o]

# Resolution
spy_cfg.InlineBackend.rc = {'figure.figsize': (6.0, 4.0),
'savefig.dpi': 72,
'font.size': 10,
'figure.subplot.bottom': .125,
'figure.facecolor': 'white',
'figure.edgecolor': 'white'
}
resolution_o = CONF.get('ipython_console',
'pylab/inline/resolution')
spy_cfg.InlineBackend.rc['savefig.dpi'] = resolution_o

# Figure size
width_o = float(CONF.get('ipython_console', 'pylab/inline/width'))
height_o = float(CONF.get('ipython_console', 'pylab/inline/height'))
spy_cfg.InlineBackend.rc['figure.figsize'] = (width_o, height_o)
# Figure format
format_o = CONF.get('ipython_console',
'pylab/inline/figure_format', 0)
formats = {0: 'png', 1: 'svg'}
spy_cfg.InlineBackend.figure_format = formats[format_o]

# Resolution
if is_module_installed('ipykernel', '<4.5'):
dpi_option = 'savefig.dpi'
else:
dpi_option = 'figure.dpi'

spy_cfg.InlineBackend.rc = {'figure.figsize': (6.0, 4.0),
dpi_option: 72,
'font.size': 10,
'figure.subplot.bottom': .125,
'figure.facecolor': 'white',
'figure.edgecolor': 'white'}
resolution_o = CONF.get('ipython_console',
'pylab/inline/resolution')
spy_cfg.InlineBackend.rc[dpi_option] = resolution_o

# Figure size
width_o = float(CONF.get('ipython_console', 'pylab/inline/width'))
height_o = float(CONF.get('ipython_console', 'pylab/inline/height'))
spy_cfg.InlineBackend.rc['figure.figsize'] = (width_o, height_o)


# Enable Cython magic
Expand Down
3 changes: 2 additions & 1 deletion spyder/widgets/ipythonconsole/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ def change_mpl_backend(self, command):
"""
if command.startswith('%matplotlib') and \
len(command.splitlines()) == 1:
self.silent_execute(command)
if not 'inline' in command:
self.silent_execute(command)

#---- Private methods (overrode by us) ---------------------------------
def _context_menu_make(self, pos):
Expand Down

0 comments on commit 9ba55e9

Please sign in to comment.