Skip to content

Commit

Permalink
Initialize empty mpl (#6128)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored and philippjfr committed Jan 17, 2024
1 parent 51ec6d3 commit c91e39a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions panel/pane/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ def _update(self, ref: str, model: Model) -> None:
manager.canvas.draw_idle()

def _data(self, obj):
if obj is None:
return

try:
obj.set_dpi(self.dpi)
except Exception as ex:
Expand Down
13 changes: 13 additions & 0 deletions panel/tests/pane/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ def test_get_matplotlib_pane_type():
assert PaneBase.get_pane_type(mpl_figure()) is Matplotlib


@mpl_available
def test_matplotlib_pane_initially_empty(document, comm):
pane = pn.pane.Matplotlib()
assert pane.object is None

model = pane.get_root(document, comm=comm)
assert model.text == '<img></img>'

pane.object = mpl_figure()
assert model.text.startswith('&lt;img src=&quot;data:image/png;base64,')
assert pane._models[model.ref['id']][0] is model


@mpl_available
def test_matplotlib_pane(document, comm):
pane = pn.pane.Matplotlib(mpl_figure())
Expand Down

0 comments on commit c91e39a

Please sign in to comment.