Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Site cannot be reached when graph using plotly

Tags:

python

plotly

I'm trying to use plotly to plot a simple graph

My code is shown as follow

import plotly.express as px

x = [1,2,3]
y = [1,2,3]
fig = px.line(x=x, y=y,labels={'x':x_name,'y':y_name})
fig.show()

when I run this code, sometimes the browser is showing This site can’t be reached

I've searched on this question 1 2 3 , but did not got any answer.

How should I solve this problem when the browser shows This site can’t be reached ?

like image 220
whtitefall Avatar asked Jul 15 '26 02:07

whtitefall


1 Answers

instead of the fig.show() try using plotly.offline.plot(fig) to plot in offline mode

more details can be found here: https://pythonbasics.org/plotly/

like image 162
nikesh el toma Avatar answered Jul 17 '26 14:07

nikesh el toma