##// END OF EJS Templates
Do not generate output for empty figures in Qt console....
Fernando Perez -
Show More
@@ -77,6 +77,11 b' def figsize(sizex, sizey):'
77
77
78 def figure_to_svg(fig):
78 def figure_to_svg(fig):
79 """Convert a figure to svg for inline display."""
79 """Convert a figure to svg for inline display."""
80 # When there's an empty figure, we shouldn't return anything, otherwise we
81 # get big blank areas in the qt console.
82 if not fig.axes:
83 return
84
80 fc = fig.get_facecolor()
85 fc = fig.get_facecolor()
81 ec = fig.get_edgecolor()
86 ec = fig.get_edgecolor()
82 fig.set_facecolor('white')
87 fig.set_facecolor('white')
@@ -240,7 +245,6 b' def import_pylab(user_ns, backend, import_all=True, shell=None):'
240
245
241 # The old pastefig function has been replaced by display
246 # The old pastefig function has been replaced by display
242 # Always add this svg formatter so display works.
247 # Always add this svg formatter so display works.
243 from IPython.zmq.pylab.backend_inline import figure_to_svg
244 from IPython.core.display import display, display_svg
248 from IPython.core.display import display, display_svg
245 svg_formatter = shell.display_formatter.formatters['image/svg+xml']
249 svg_formatter = shell.display_formatter.formatters['image/svg+xml']
246 svg_formatter.for_type_by_name(
250 svg_formatter.for_type_by_name(
@@ -101,11 +101,12 b' def test_for(mod, min_version=None):'
101 have = {}
101 have = {}
102
102
103 have['curses'] = test_for('_curses')
103 have['curses'] = test_for('_curses')
104 have['matplotlib'] = test_for('matplotlib')
105 have['pexpect'] = test_for('pexpect')
106 have['pymongo'] = test_for('pymongo')
104 have['wx'] = test_for('wx')
107 have['wx'] = test_for('wx')
105 have['wx.aui'] = test_for('wx.aui')
108 have['wx.aui'] = test_for('wx.aui')
106 have['pexpect'] = test_for('pexpect')
107 have['zmq'] = test_for('zmq', '2.1.4')
109 have['zmq'] = test_for('zmq', '2.1.4')
108 have['pymongo'] = test_for('pymongo')
109
110
110 #-----------------------------------------------------------------------------
111 #-----------------------------------------------------------------------------
111 # Functions and classes
112 # Functions and classes
@@ -191,6 +192,11 b' def make_exclude():'
191 if not have['pymongo']:
192 if not have['pymongo']:
192 exclusions.append(ipjoin('parallel', 'controller', 'mongodb'))
193 exclusions.append(ipjoin('parallel', 'controller', 'mongodb'))
193
194
195 if not have['matplotlib']:
196 exclusions.extend([ipjoin('lib', 'pylabtools'),
197 ipjoin('lib', 'pylabtools',
198 'tests', 'test_pylabtools')])
199
194 # This is needed for the reg-exp to match on win32 in the ipdoctest plugin.
200 # This is needed for the reg-exp to match on win32 in the ipdoctest plugin.
195 if sys.platform == 'win32':
201 if sys.platform == 'win32':
196 exclusions = [s.replace('\\','\\\\') for s in exclusions]
202 exclusions = [s.replace('\\','\\\\') for s in exclusions]
@@ -6,7 +6,9 b''
6 from __future__ import print_function
6 from __future__ import print_function
7
7
8 # Standard library imports
8 # Standard library imports
9 import sys
9
10
11 # Third-party imports
10 import matplotlib
12 import matplotlib
11 from matplotlib.backends.backend_svg import new_figure_manager
13 from matplotlib.backends.backend_svg import new_figure_manager
12 from matplotlib._pylab_helpers import Gcf
14 from matplotlib._pylab_helpers import Gcf
@@ -64,7 +66,15 b' def flush_svg():'
64 def send_svg_figure(fig):
66 def send_svg_figure(fig):
65 """Draw the current figure and send it as an SVG payload.
67 """Draw the current figure and send it as an SVG payload.
66 """
68 """
69 # For an empty figure, don't even bother calling figure_to_svg, to avoid
70 # big blank spaces in the qt console
71 if not fig.axes:
72 return
73
67 svg = figure_to_svg(fig)
74 svg = figure_to_svg(fig)
75 # flush text streams before sending figures, helps a little with output
76 # synchronization in the console (though it's a bandaid, not a real sln)
77 sys.stdout.flush(); sys.stderr.flush()
68 publish_display_data(
78 publish_display_data(
69 'IPython.zmq.pylab.backend_inline.send_svg_figure',
79 'IPython.zmq.pylab.backend_inline.send_svg_figure',
70 'Matplotlib Plot',
80 'Matplotlib Plot',
General Comments 0
You need to be logged in to leave comments. Login now