[Python] How to export plotly graphs in jupyter notebook as HTML?

Discussão em 'Python' iniciado por Stack, Junho 11, 2025.

  1. Stack

    Stack Membro Participativo

    I am currently using PyCharm on Fedora. I have a jupyter notebook with plotly graphs. Following are my imports

    import plotly.graph_objects as go

    fig = go.Figure(
    data=go.Scatter(
    x=simulation_results_df['expected_risk'],
    y=simulation_results_df['expected_return'],
    mode='markers',
    name = "Simulated Portfolios",
    hovertemplate="Expected Volatility/Risk: %{x}<br>Expected Return: %{y}<extra></extra>",
    showlegend=True
    )
    )

    fig.update_layout(
    title="Simulated Portfolios",
    xaxis_title="Expected Volatility/Risk",
    yaxis_title="Expected Return",
    width=800,
    height=600,
    showlegend=False)

    fig.update_xaxes(showspikes=True)
    fig.update_yaxes(showspikes=True)

    fig.show()


    The graph gets displayed just fine in the .ipynb file.

    I use the PyCharm option to export notebook as HTML. When I open the .html file in PyCharm browser I cannot see the graph. I have tried couple of methods such as specifying the renderer but nothing seems to work. Does this have anything to do with PyCharm? I see that some solutions have worked for others while using jupyterlab

    Continue reading...

Compartilhe esta Página