Skip to content

Commit ad406cd

Browse files
committed
Update plot display method to avoid warnings
1 parent 82bcc49 commit ad406cd

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/easydiffraction/plotting/plotters/plotter_plotly.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,20 @@ def plot(
107107

108108
# Show the figure
109109

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-
print(
114-
f'----DEBUG----: fig.show(): is_notebook()={is_notebook()}, is_pycharm()={is_pycharm()}, '
115-
f'display={display}, HTML={HTML}'
116-
)
110+
# The standard `fig.show()` method method triggers the following
111+
# warning during the DMSC Summer School 2025 book build process:
112+
# WARNING: skipping unknown output mime type:
113+
# application/vnd.plotly.v1+json [mystnb.unknown_mime_type]
114+
# So, instead, we will use `pio.to_html()` to convert the figure
115+
# to HTML and keep `fig.show()` in PyCharm only.
116+
117+
if is_pycharm() or display is None or HTML is None:
117118
fig.show(config=config)
118-
119-
# If IPython is available, we can convert the figure to HTML and
120-
# display it in the notebook.
121119
else:
122-
# Convert figure to HTML
123120
html_fig = pio.to_html(
124121
fig,
125122
include_plotlyjs='cdn',
126123
full_html=False,
127124
config=config,
128125
)
129-
130-
# Display it in the notebook
131-
print('----DEBUG----: display(HTML(html_fig))')
132126
display(HTML(html_fig))

0 commit comments

Comments
 (0)