Aggregate hover data for internal nodes in hierarchical plots
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 18.8k
- Forks
- 2.8k
- Ø Merge
- 16 Std. 26 Min.
- Gemergte PRs (30 T.)
- 21
Beschreibung
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?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem für px.treemap, px.icicle und px.sunburst beschriebenen Verhalten hierarchischer Diagramme und verwende das bereitgestellte Gapminder-Beispiel mit numerischen hover_data. Ermittle, wie hover_data für interne Knoten derzeit aggregiert wird und wie eine Aggregationsfunktion verfügbar gemacht werden könnte. Als erledigt gilt die Aufgabe, wenn numerische Hover-Felder an internen Knoten aggregiert werden, während diskrete Felder ihr bisheriges Verhalten beibehalten, und die angeforderte Option unterstützt wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- data-visualization
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100