@@ -497,7 +497,7 @@ def show(fig, renderer=None, validate=True, **kwargs):
497
497
)
498
498
499
499
default_renderer = env_renderer
500
- elif ipython and ipython . get_ipython () :
500
+ elif ipython :
501
501
# Try to detect environment so that we can enable a useful
502
502
# default renderer
503
503
if not default_renderer :
@@ -543,13 +543,19 @@ def show(fig, renderer=None, validate=True, **kwargs):
543
543
pass
544
544
545
545
# 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" ):
549
549
default_renderer = "browser"
550
550
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
+
551
557
# 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
553
559
# nbconvert HTML export.
554
560
if not default_renderer :
555
561
default_renderer = "plotly_mimetype+notebook"
0 commit comments