I`m using an Icicle chart to data from a hierarchy perspective, with a button to adjust the values shown. The following is an example of my code:
df = pd.DataFrame({
'YEAR': ['2023', '2023', '2023', '2023'],
'COMPANY': ['Company A','Company A','Company A','Company A'],
'ORG': ['People', 'People', 'Customer', 'Customer'],
'DEPARTMENT': ['HR', 'HR', 'Marketing', 'Marketing'],
'AREA': ['Reward', 'Benefits', 'Campaigns', 'Insights'],
'Employees': [5, 4, 9, 11],
'Salary Cost' : [80000,75000,113000,140000]
})
figs = {
c: px.icicle(df, path=["COMPANY","ORG", "DEPARTMENT", "AREA"], values=c, color='AREA', height=700)
for c in ["Employees", "Salary Cost"]
}
fig = figs["Employees"]
#Button for FTE and HC
fig.update_layout(
updatemenus=[
{
"buttons": [
{
"label": c, #FTE or HC, needs to match df column names
"method": "restyle",
"args": [
{
"values": [figs[c].data[0].values],
"hovertemplate": figs[c].data[0].hovertemplate,
}
],
}
for c in figs.keys()
]
}
]
)
I`d like the icicle chart to be top down rather than right to left. Looking at the plotly documentation, there is an example however this is under the graph_objects and not all the same features are available.
They have an example of the vertical orientation in their docs. Here's a demonstration of how to apply this on your code.