Skip to content
← Back to Community
Displaying Plotly graph written in HTML file
Profile icon
OzkanOzturk

Can anyone help me please:
I can not display the graph in browser which is saved in html file by fig.write_html or Plotly.offline.plot even auto_open is true.
I am expecting a new tab or file open in browser which is g.chrome and show html but nothing happens.

Voters
Profile icon
OzkanOzturk
Comments
hotnewtop
Profile icon
[deleted]

Your expecting your repl to open a new tab in your broswer, but replit cant do that. What you can do is learn how to use the flask module to load the webpage and display it. I'm not an expert on flask, but there are good tutorials on the internet

Profile icon
nucklehead

This might be late but if anyone is looking for a solution you can use Dash to provide an http server and serve the chart as an html page. See the example here: https://plotly.com/python/line-charts/#line-charts-in-dash

Here is an example code

import plotly.graph_objects as go import dash import dash_core_components as dcc import dash_html_components as html fig = go.Figure(data=go.Bar(y=[2, 3, 1])) app = dash.Dash(__name__) app.layout = html.Div([ dcc.Graph(id="line-chart", figure=fig), ]) app.run_server(host="0.0.0.0", debug=True)
Profile icon
AdityaChaudhar4

sadly i am still not able to render plotly graph in replit

Profile icon
OzkanOzturk

@tangert hi. Could you please have a look at my question?

Profile icon
tangert

hi @OzkanOzturk, sorry for the late response! I was sick. can you please provide a link to the repl or make a new post with it so we can reproduce the error?

Profile icon
AdityaChaudhar4

@tangert hey, i am having the same issue!

plotly graphs don't render at all while matplotlib works fine