plotly / plotly/plotly.py

figure_factory create_hexbin_mapbox ignored agg_func

Đang mở
#4,632 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug P3 sev-4
Ngôn ngữ chính
Python
Star
18.8k
Fork
2.8k
Merge trung bình
16 giờ 26 phút
Pull request đã merge (30 ngày)
21

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu từ điểm vào của figure_factory, ff.create_hexbin_mapbox, và tái hiện vấn đề bằng DataFrame được cung cấp cùng các ví dụ np.min, np.mean và np.max. Theo dõi cách agg_func được truyền vào quá trình tạo hexbin, sau đó xác minh rằng các giá trị hexbin_data.z thu được khác nhau phù hợp với từng hàm tổng hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
numpy, pandas, plotly, python
Lĩnh vực
data-visualization
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.