Skip to content

Commit 4a2f699

Browse files
committed
Make default renderer in jupyterlab/notebook plotly_mimetype
1 parent 0ee60e7 commit 4a2f699

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

plotly/io/_renderers.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ def show(fig, renderer=None, validate=True, **kwargs):
497497
)
498498

499499
default_renderer = env_renderer
500-
elif ipython and ipython.get_ipython():
500+
elif ipython:
501501
# Try to detect environment so that we can enable a useful
502502
# default renderer
503503
if not default_renderer:
@@ -543,13 +543,19 @@ def show(fig, renderer=None, validate=True, **kwargs):
543543
pass
544544

545545
# Check if we're running in ipython terminal
546-
if not default_renderer and (
547-
ipython.get_ipython().__class__.__name__ == "TerminalInteractiveShell"
548-
):
546+
ipython_info = ipython.get_ipython()
547+
shell = ipython_info.__class__.__name__
548+
if not default_renderer and (shell == "TerminalInteractiveShell"):
549549
default_renderer = "browser"
550550

551+
# Check if we're running in a Jupyter notebook or JupyterLab
552+
if not default_renderer and (shell == 'ZMQInteractiveShell') and (
553+
type(ipython_info).__module__.startswith('ipykernel.')
554+
):
555+
default_renderer = 'plotly_mimetype'
556+
551557
# Fallback to renderer combination that will work automatically
552-
# in the classic notebook, jupyterlab, nteract, vscode, and
558+
# in the jupyter notebook, jupyterlab, nteract, vscode, and
553559
# nbconvert HTML export.
554560
if not default_renderer:
555561
default_renderer = "plotly_mimetype+notebook"

0 commit comments

Comments
 (0)