plotly / plotly/plotly.py

px.area() ignores color_discrete_sequence or color_discrete_map when mode='none'

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

@LiamConnors đang làm issue này rồi.

Từ ngày 4/7/2024.

bug documentation 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ả

If I want to display just the shaded area in px.area(), without the top line, by specifying mode='none', the colors set with color_discrete_sequence or color_discrete_map are ignored. Instead, default colors of the template fig.layout.template.layout.colorway are used.

import plotly.express as px
import pandas as pd

fig = px.area(
    pd.DataFrame(
        index=[1,2,3],
        data={
            'x': [6,7,8],
            'y': [4,5,4],
        }
    ),
    color_discrete_map={
        'x': '#9467BD',
        'y': '#8C564B',
    },
)

fig.show()

1

If I add

fig.update_traces(
    mode='none',
)

I get wrong colors
2

I would expect px.area() to preserve the colors used for shading as they appear in fig.data:

     'line': {'color': '#9467BD'},
     'mode': 'none',
     'line': {'color': '#8C564B'},
     'mode': 'none',

Without this preservation, px.area() loses functionality for color mapping with color_discrete_map.

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.

Đánh giá

Issue này chưa được đánh giá.

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.