Hi folks,
I am trying to plot some categorical/hierarchical data with Icicle chart. I have positive and negative values in profit column that I would like to use as a value parameter.
Does it make sense to have both positive and negative value in Icicle chart? When I leave negative values, chart does not work!
Thanks!
import pandas as pd
import plotly.express as px
df = pd.read_table('https://raw.githubusercontent.com/milanzmitrovic/Global-Super-Store/main/Data/Orders.tsv')
df = df.assign(profit_derived=lambda x: x['Profit'].str.replace(',', '.').astype('float'))
df = (df[[
'profit_derived',
'Segment',
'Region',
'Ship Mode',
'City'
]])
df = df.query(expr="profit_derived > 0")
df_grouped = df.groupby(by=['Segment', 'Region', 'Ship Mode', 'City']).sum().reset_index()
fig = px.icicle(dff, path=['Region', 'Ship Mode', 'City'], values='profit_derived')
fig.update_traces(root_color="lightgrey")
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
fig.show()