Reputation: 31
I'm trying to plot a sunburst with plotly express, but the output is a complete blank plot. The code below is from an example showed on the plotly site.
All the examples with path
give me this output.
import plotly.express as px
df = px.data.tips()
fig = px.sunburst(df, path=['day', 'time', 'sex'], values='total_bill')
fig.show()
Upvotes: 3
Views: 1755
Reputation: 1
Do you have some negative values in your 'total_bill' field?
I found that Sunburst plot returns a blank if the column specified by the 'values' has some negative values. When I drop rows with negative values, the chart renders fine. I don't know if this is a bug though.
I'm running Plotly 5.4.0/Python 3.8.10 in WSL2 on Windows 10.
Upvotes: 0
Reputation: 3082
You are not providing valid data. This is what it should be
import plotly.express as px
data = dict(
character=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
parent=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve" ],
value=[10, 14, 12, 10, 2, 6, 6, 4, 4])
fig = px.sunburst(
data,
names='character',
parents='parent',
values='value',
)
fig.show()
Enjoy!
Upvotes: -2