Skip to content

Commit 167ce13

Browse files
Merge pull request #64 from easyscience/patch
Fix Plotly display warning
2 parents 2b5600a + 63def73 commit 167ce13

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/easydiffraction/plotting/plotters/plotter_plotly.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
display = None
1313
HTML = None
1414

15-
from easydiffraction.utils.utils import is_notebook
1615
from easydiffraction.utils.utils import is_pycharm
1716

1817
from .plotter_base import SERIES_CONFIG
@@ -107,21 +106,20 @@ def plot(
107106

108107
# Show the figure
109108

110-
# This can lead to warnings in Jupyter notebooks:
111-
# WARNING: skipping unknown output mime type: application/vnd.plotly.v1+json [mystnb.unknown_mime_type]
112-
if is_notebook() or is_pycharm() or display is None or HTML is None:
113-
fig.show(config=config)
109+
# The standard `fig.show()` method method triggers the following
110+
# warning during the DMSC Summer School 2025 book build process:
111+
# WARNING: skipping unknown output mime type:
112+
# application/vnd.plotly.v1+json [mystnb.unknown_mime_type]
113+
# So, instead, we will use `pio.to_html()` to convert the figure
114+
# to HTML and keep `fig.show()` in PyCharm only.
114115

115-
# If IPython is available, we can convert the figure to HTML and
116-
# display it in the notebook.
116+
if is_pycharm() or display is None or HTML is None:
117+
fig.show(config=config)
117118
else:
118-
# Convert figure to HTML
119119
html_fig = pio.to_html(
120120
fig,
121121
include_plotlyjs='cdn',
122122
full_html=False,
123123
config=config,
124124
)
125-
126-
# Display it in the notebook
127125
display(HTML(html_fig))

0 commit comments

Comments
 (0)