Skip to content

figure_factory create_hexbin_mapbox ignored agg_func #4632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
do-me opened this issue Jun 11, 2024 · 0 comments
Open

figure_factory create_hexbin_mapbox ignored agg_func #4632

do-me opened this issue Jun 11, 2024 · 0 comments
Labels
bug something broken P3 backlog sev-4 cosmetic

Comments

@do-me
Copy link

do-me commented Jun 11, 2024

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.

@Coding-with-Adam Coding-with-Adam added bug something broken sev-4 cosmetic labels Jun 25, 2024
@gvwilson gvwilson self-assigned this Jul 12, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added the P3 backlog label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog sev-4 cosmetic
Projects
None yet
Development

No branches or pull requests

3 participants