plotly / plotly/plotly.py

figure_factory create_hexbin_mapbox ignored agg_func

Offen
#4,632 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P3 sev-4
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

As the title states, the aggregation function is entirely ignored and it does not make any difference whether you insert np.mean, np.min or np.max. Using plotly==5.22.0

Example:

  1. Generate data
import plotly.figure_factory as ff
import pandas as pd
import numpy as np

# Mock GeoDataFrame with latitude, longitude, and value columns
np.random.seed(0)
num_points = 1000
data = {
    'lat': np.random.uniform(40, 45, num_points),
    'lon': np.random.uniform(-75, -70, num_points),
    'value': np.random.uniform(0, 1, num_points)
}
df = pd.DataFrame(data)
df
  1. Plot and check vals

fig = ff.create_hexbin_mapbox(
    data_frame=df, lat="lat", lon="lon",
    nx_hexagon=50,  # Decrease the size of hexagons
    opacity=0.5, labels={"color": "value"},
    color_continuous_scale="Viridis",
    agg_func=np.min,  # or np.max aggregation
    show_original_data=True,
    original_data_marker=dict(size=1.1, opacity=0.6, color="deeppink")
)

# Extract the hexbin data
hexbin_data = fig.data[0]

# Check the hexbin values
print("Hexbin values (z):", hexbin_data.z)

# Update the text of each hexagon to display the maximum value
hexbin_data.hovertemplate = 'Value: %{z}<extra></extra>'

# Update the layout to use OSM tiles
fig.update_layout(
    mapbox_style="open-street-map",
    height=800  # Set the desired height
)

fig.show()

Output for np.min, np.mean and np.max is identical:

Hexbin values (z): [0. 0. 0. ... 0. 1. 0.]

Hence, the plot does not change.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie am figure_factory-Einstiegspunkt ff.create_hexbin_mapbox und reproduzieren Sie das Problem mit dem bereitgestellten DataFrame sowie den Beispielen np.min, np.mean und np.max. Verfolgen Sie, wie agg_func an die Hexbin-Generierung übergeben wird, und überprüfen Sie anschließend, dass sich die resultierenden hexbin_data.z-Werte für jede Aggregationsfunktion entsprechend unterscheiden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
numpy, pandas, plotly, python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.