Skip to content

Commit 484b5fe

Browse files
committed
adding header_visible toggle to hide or show the title/header in mpl figure
1 parent 089e820 commit 484b5fe

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

ipympl/backend_nbagg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ class Canvas(DOMWidget, FigureCanvasWebAggCore):
149149
toolbar = Instance(Toolbar, allow_none=True).tag(sync=True, **widget_serialization)
150150
toolbar_visible = Bool(True).tag(sync=True)
151151
toolbar_position = Enum(['top', 'bottom', 'left', 'right'], default_value='left').tag(sync=True)
152+
153+
header_visible = Bool(True).tag(sync=True)
154+
152155
_closed = Bool(True)
153156

154157
# Must declare the superclass private members.

js/src/mpl_widget.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var MPLCanvasModel = widgets.DOMWidgetModel.extend({
1616
_view_module: 'jupyter-matplotlib',
1717
_model_module_version: '^'+ version,
1818
_view_module_version: '^' + version,
19+
header_visible: true,
1920
toolbar: null,
2021
toolbar_visible: true,
2122
toolbar_position: 'horizontal'
@@ -64,6 +65,7 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
6465

6566
model_events: function() {
6667
this.model.on('msg:custom', this.on_comm_message.bind(this));
68+
this.model.on('change:header_visible', this.update_header_visible.bind(this));
6769
this.model.on('change:toolbar_visible', this.update_toolbar_visible.bind(this));
6870
this.model.on('change:toolbar_position', this.update_toolbar_position.bind(this));
6971
},
@@ -78,6 +80,11 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
7880
this.send_message('initialized');
7981
},
8082

83+
update_header_visible: function() {
84+
this.header.style.display = this.model.get('header_visible') ? '': 'none';
85+
this.request_resize();
86+
},
87+
8188
update_toolbar_visible: function() {
8289
this.toolbar_view.el.style.display = this.model.get('toolbar_visible') ? '' : 'none';
8390
this.request_resize();

0 commit comments

Comments
 (0)