Skip to content

Commit

Permalink
Added general Renderer.notebook_context attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Apr 19, 2017
1 parent a3ad189 commit 0111083
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions holoviews/ipython/__init__.py
Expand Up @@ -221,6 +221,7 @@ def __call__(self, *args, **params):
resources = list(resources)
if len(resources) == 0: return

Renderer.load_nb()
for r in [r for r in resources if r != 'holoviews']:
Store.renderers[r].load_nb(inline=p.inline)

Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/mpl/plot.py
Expand Up @@ -138,7 +138,7 @@ def __init__(self, fig=None, axis=None, **params):
if self.renderer.interactive:
plt.ion()
self._close_figures = False
elif not self.renderer._notebook:
elif not self.renderer.notebook_context:
plt.ioff()

with mpl.rc_context(rc=self.fig_rcparams):
Expand Down
4 changes: 0 additions & 4 deletions holoviews/plotting/mpl/renderer.py
Expand Up @@ -93,9 +93,6 @@ class MPLRenderer(Renderer):
'nbagg': (NbAggJupyterComm, None),
'mpld3': (JupyterComm, mpld3_msg_handler)}

# Whether in a notebook context
_notebook = False

def __call__(self, obj, fmt='auto'):
"""
Render the supplied HoloViews component or MPLPlot instance
Expand Down Expand Up @@ -321,4 +318,3 @@ def load_nb(cls, inline=True):
"""
import matplotlib.pyplot as plt
plt.switch_backend('agg')
cls._notebook = True
6 changes: 6 additions & 0 deletions holoviews/plotting/renderer.py
Expand Up @@ -150,6 +150,9 @@ class Renderer(Exporter):
# Any additional JS and CSS dependencies required by a specific backend
backend_dependencies = {}

# Whether in a notebook context, set when running Renderer.load_nb
notebook_context = False

def __init__(self, **params):
self.last_plot = None
super(Renderer, self).__init__(**params)
Expand Down Expand Up @@ -516,3 +519,6 @@ def load_nb(cls, inline=True):
Loads any resources required for display of plots
in the Jupyter notebook
"""
with param.logging_level('ERROR'):
cls.notebook_context = True

0 comments on commit 0111083

Please sign in to comment.