Output of plotly to_html() method is not displayed in Jupyter Notebook

When creating an html from a plotly plot using the to_hmtl method, the generated html can be displayed correctly using display(HTML(x)) when using JupyterLab but is not displayed correctly when using Jupyter Notebook (nothing is displayed).

Also, when trying to export the Jupyter Lab notebook to hmtl using nbconvert, the plotly plot are not correctly shown in the generated html (although they are rendered correctly in the JupyterLab Notebook)

Python Code

import plotly.graph_objs as go
from IPython.display import HTML, display

# Create some sample data
x = [1, 2, 3, 4, 5]
y = [1, 4, 9, 16, 25]

# Create a trace
trace = go.Scatter(
    x=x,
    y=y,
    mode='markers',
    marker=dict(
        size=10,
        color='blue'
    )
)

# Create a data list with the trace
data = [trace]

# Create a layout
layout = go.Layout(
    title='Example Scatter Plot',
    xaxis=dict(title='X-axis'),
    yaxis=dict(title='Y-axis')
)

# Create a figure with the data and layout
fig = go.Figure(data=data, layout=layout)

html_fig = fig.to_html()

display(HTML(html_fig))

For further information you can also see the original post on StackOverflow https://stackoverflow.com/q/77317461/21157254