Show More
@@ -77,6 +77,11 b' def figsize(sizex, sizey):' | |||
|
77 | 77 | |
|
78 | 78 | def figure_to_svg(fig): |
|
79 | 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 | 85 | fc = fig.get_facecolor() |
|
81 | 86 | ec = fig.get_edgecolor() |
|
82 | 87 | fig.set_facecolor('white') |
@@ -240,7 +245,6 b' def import_pylab(user_ns, backend, import_all=True, shell=None):' | |||
|
240 | 245 | |
|
241 | 246 | # The old pastefig function has been replaced by display |
|
242 | 247 | # Always add this svg formatter so display works. |
|
243 | from IPython.zmq.pylab.backend_inline import figure_to_svg | |
|
244 | 248 | from IPython.core.display import display, display_svg |
|
245 | 249 | svg_formatter = shell.display_formatter.formatters['image/svg+xml'] |
|
246 | 250 | svg_formatter.for_type_by_name( |
@@ -101,11 +101,12 b' def test_for(mod, min_version=None):' | |||
|
101 | 101 | have = {} |
|
102 | 102 | |
|
103 | 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 | 107 | have['wx'] = test_for('wx') |
|
105 | 108 | have['wx.aui'] = test_for('wx.aui') |
|
106 | have['pexpect'] = test_for('pexpect') | |
|
107 | 109 | have['zmq'] = test_for('zmq', '2.1.4') |
|
108 | have['pymongo'] = test_for('pymongo') | |
|
109 | 110 | |
|
110 | 111 | #----------------------------------------------------------------------------- |
|
111 | 112 | # Functions and classes |
@@ -191,6 +192,11 b' def make_exclude():' | |||
|
191 | 192 | if not have['pymongo']: |
|
192 | 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 | 200 | # This is needed for the reg-exp to match on win32 in the ipdoctest plugin. |
|
195 | 201 | if sys.platform == 'win32': |
|
196 | 202 | exclusions = [s.replace('\\','\\\\') for s in exclusions] |
@@ -6,7 +6,9 b'' | |||
|
6 | 6 | from __future__ import print_function |
|
7 | 7 | |
|
8 | 8 | # Standard library imports |
|
9 | import sys | |
|
9 | 10 | |
|
11 | # Third-party imports | |
|
10 | 12 | import matplotlib |
|
11 | 13 | from matplotlib.backends.backend_svg import new_figure_manager |
|
12 | 14 | from matplotlib._pylab_helpers import Gcf |
@@ -64,7 +66,15 b' def flush_svg():' | |||
|
64 | 66 | def send_svg_figure(fig): |
|
65 | 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 | 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 | 78 | publish_display_data( |
|
69 | 79 | 'IPython.zmq.pylab.backend_inline.send_svg_figure', |
|
70 | 80 | 'Matplotlib Plot', |
General Comments 0
You need to be logged in to leave comments.
Login now