Using plotly and getting "This site can't be reached"
Chuck Untulis
chuck.untulis at gmail.com
Sat Jan 16 19:44:01 EST 2021
The Chrome browser on the machine shows "127.0.0.1 refused to connect" for
various urls of the form 127.0.0.1:xxxxx where xxxxx are numbers like
64981, 65029,... About once in 20-40 attempts, the graphs appear.
I ran the same code on a different machine and it created the plots in the
Chrome browser every time. I ran a different Python plotly program on both
machines with similar results.
Everything else I navigate to in Chrome works as expected.
No errors are reported by the plotly code shown below. I also ran the code
in Visual Studio Code with the same results.
I would like to see the information sent to the browser but I have not
figured out how to do that yet.
Any help would be appreciated.
=====================================================
import pandas as pd
df = pd.DataFrame({
"Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
"Contestant": ["Alex", "Alex", "Alex", "Jordan", "Jordan", "Jordan"],
"Number Eaten": [2, 1, 3, 1, 3, 2],
})
import plotly.express as px
fig = px.bar(df, x="Fruit", y="Number Eaten", color="Contestant", barmode=
"group")
#print(""PLOT 1")
# fig.show()
import plotly.graph_objects as go
fig = go.Figure()
for contestant, group in df.groupby("Contestant"):
fig.add_trace(go.Bar(x=group["Fruit"], y=group["Number Eaten"], name
=contestant,
hovertemplate="Contestant=%s<br>Fruit=%%{x}<br>Number Eaten=%%{y}
<extra></extra>"% contestant))
fig.update_layout(legend_title_text = "Contestant")
fig.update_xaxes(title_text="Fruit")
fig.update_yaxes(title_text="Number Eaten")
print("PLOT 2")
fig.show()
More information about the Python-list
mailing list