figure_factory create_hexbin_mapbox ignored agg_func
未关闭
还没有人认领这个 Issue。
bug
P3
sev-4
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
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:
- 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
- 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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 figure_factory 入口点 ff.create_hexbin_mapbox 开始,使用提供的 DataFrame 以及 np.min、np.mean 和 np.max 示例复现该问题。跟踪 agg_func 如何传入 hexbin 生成过程,然后验证生成的 hexbin_data.z 值是否针对每个聚合函数进行了适当的区分。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- numpy, pandas, plotly, python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 38/100