Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add option for displaying figures below cells that create them. #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bluesky_widgets/jupyter/figures.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ipywidgets import widgets
from IPython.display import display
import ipympl.backend_nbagg
import matplotlib.figure

Expand Down Expand Up @@ -48,9 +49,10 @@ class JupyterFigures(widgets.Tab):
A Jupyter (ipywidgets) view for a FigureList model.
"""

def __init__(self, model: FigureList, *args, **kwargs):
def __init__(self, model: FigureList, *args, display_in_current_output=False, **kwargs):
_initialize_mpl()
super().__init__(*args, **kwargs)
self.display_in_current_output = display_in_current_output
self.model = model
# Map Figure UUID to widget with JupyterFigureTab
self._figures = {}
Expand All @@ -73,6 +75,8 @@ def _add_figure(self, figure_spec):
"Add a new tab with a matplotlib Figure."
tab = _JupyterFigureTab(figure_spec, parent=self)
self._figures[figure_spec.uuid] = tab
if self.display_in_current_output:
display(tab.figure.canvas)
self.children = (*self.children, tab)
index = len(self.children) - 1
self.set_title(index, figure_spec.title)
Expand Down