plotly / plotly/plotly.py

px.density_contour() ignores color labels for negative histfunc results

Đang mở
#3,799 1 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
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ả

Consider the following example:

import plotly.express as px
import pandas as pd
import numpy as np
import plotly


np.random.seed(0)

n_samples = 1000
df = pd.DataFrame({
    'x': np.random.randint(low=1, high=5, size=n_samples),
    'y': np.random.randint(low=1, high=4, size=n_samples),
    'z': np.random.normal(loc=-40, scale=20, size=n_samples),
})

df['z'] = df['z'] * df['x']

# uncomment to make some values above 0
# df['z'] = df['z'] + 80

# uncomment to make all values above 0
# df['z'] = df['z'].abs()

fig = px.density_contour(df, x='x', y='y', z='z', histfunc='avg', height=800, width=1200, title=f'Plotly version: {plotly.__version__}')
fig.update_traces(contours_coloring="fill", contours_showlabels=True)
fig.show()

It calculates average of mostly negative values, which results in the following plot:
image

Color bar has correct color range, but all data points use same color - yellow, which is not particularly useful. Similar situation happens when only part of data is negative (uncomment first commented line in the example):

image
Left (positive) section looks fine, while right (negative) is colored with only one color.

There are workarounds, that involve changing of input data, but this makes plot reading much harder.

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 bằng cách chạy ví dụ px.density_contour() được cung cấp với các kết quả histfunc âm và hỗn hợp, sau đó kiểm tra điểm vào density_contour và cách tô màu đường đồng mức xử lý các giá trị đó. Được xem là hoàn tất khi các kết quả âm và hỗn hợp sử dụng toàn bộ dải màu thay vì bị thu gọn thành một màu, đồng thời trường hợp dương hiện có vẫn đúng.

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, 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
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
65/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.