Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89c88e7

Browse files
committed
Hook up the save_figure function
1 parent c2fb2a4 commit 89c88e7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/matplotlib/backends/backend_webagg_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def release_zoom(self, event):
329329

330330
def save_figure(self, *args):
331331
"""Save the current figure"""
332-
warnings.warn('"Save figure" not implemented in Web Backend')
332+
self.canvas.send_event('save')
333333

334334

335335
class FigureManagerWebAgg(backend_bases.FigureManagerBase):

lib/matplotlib/backends/web_backend/mpl.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ mpl.figure.prototype.send_draw_message = function() {
283283
}
284284
}
285285

286+
287+
mpl.figure.prototype.handle_save = function(fig, msg) {
288+
var format_dropdown = fig.format_dropdown;
289+
var format = format_dropdown.options[format_dropdown.selectedIndex].value;
290+
fig.ondownload(fig, format);
291+
}
292+
293+
286294
mpl.figure.prototype.handle_resize = function(fig, msg) {
287295
var size = msg['size'];
288296
if (size[0] != fig.canvas.width || size[1] != fig.canvas.height) {

0 commit comments

Comments
 (0)