Aggregate hover data for internal nodes in hierarchical plots
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Hierarchical plots constructed with px.treemap, px.icicle, and px.sunburst, aggregate data at internal nodes as follows:
values: sum of children,color:values-weighted sum of children ifdf[color]is numeric, else "discrete aggregation",hover_data: only supports "discrete aggregation",
where for "discrete aggregation", the value of an internal node is mapped to that of its children if all its children have the same value, otherwise the aggregated value is set to"(?)".
Below is an example of a treemap with 2 quantities in hover data, one of which is numeric and could be aggregated at internal nodes, but instead all non-leaf nodes get a "(?)":
df = px.data.gapminder().query("year == 2007")
df["quantity_to_aggregate"] = np.random.random(df.shape[0])
fig = px.treemap(
df,
path=[px.Constant("world"), "continent", "country"],
values="pop",
color="lifeExp",
hover_data=["iso_alpha", "quantity_to_aggregate"],
color_continuous_scale="RdBu",
color_continuous_midpoint=np.average(df["lifeExp"], weights=df["pop"]),
)
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
fig.show()
Is it possible to aggregate numeric hover_data in hierarchical plots, perhaps as a sum initially, but potentially also giving the option to apply a different function?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the hierarchical plot behavior described for px.treemap, px.icicle, and px.sunburst, using the provided Gapminder example with numeric hover_data. Determine how internal-node hover_data is currently aggregated and how an aggregation function could be exposed. Done means numeric hover fields aggregate at internal nodes while discrete fields retain their existing behavior, with the requested option supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100