plotly / plotly/plotly.py

tickvals and ticktext don't work with subcategory axes

Đang mở
#2,395 5 bình luận 9 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ả

If a plot has multi-category axes there is no way to hide a subcategory labels only and the plot doesn't render at all if tickvals and ticktext are used.

Look at the code without multi-categories:

x_names = ['very.long.name.1', 'very.long.name.2', 'very.long.name.3']
fig = go.Figure(go.Bar(
    x=x_names,
    y=[10, 20, 30]))
fig.update_layout(
    xaxis=dict(
        tickvals=x_names,
        ticktext=['', '', ''],
    ))

This works fine and all x-axes labels are hidden. I could achieve the same thing with this:
fig.update_layout(xaxis=dict(showticklabels=False))

However, if this is a multi-category plot it doesn't work at all:

x_names = [['A', 'A', 'B'], ['very.long.name.1', 'very.long.name.2', 'very.long.name.3']]
fig = go.Figure(go.Bar(
    x=x_names,
    y=[10, 20, 30]))
fig.update_layout(
    xaxis=dict(
        tickvals=x_names,
        ticktext=[['A', 'A', 'B'], ['', '', '']],
    ))

Setting showticklabels=False hides everything and I didn't find a way to hide just a single category labels.

What is really surprising this doesn't work either even if this doesn't change anything:

x_names = [['A', 'A', 'B'], ['very.long.name.1', 'very.long.name.2', 'very.long.name.3']]
fig = go.Figure(go.Bar(
    x=x_names,
    y=[10, 20, 30]))
fig.update_layout(
    xaxis=dict(
        tickvals=x_names,
        ticktext=x_names,
    ))

I believe it should work like this:

  • tickvals and ticktext work fine with a multi-category plots
  • showticklabels should accept a list of booleans, .e.g. [True, False] to be able to hide a given subcategory if this is a multi-category plot

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 tái hiện các ví dụ về một danh mục và nhiều danh mục trong issue, rồi so sánh hành vi của các trục thu được. Theo dõi cách các trục nhiều danh mục xử lý xaxis.tickvals, ticktext và showticklabels; hoàn tất khi tickvals và ticktext hoạt động עבור các biểu đồ nhiều danh mục và có thể ẩn nhãn của từng danh mục.

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

Đánh giá

Công nghệ
python
Lĩnh vực
data-visualization
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/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.