plotly / plotly/plotly.py

Sunburst plots override font size and don't position unreadable labels outside

Open
#2,029 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

Hi everyone,

just discovered sunburst plots and am loving them! Besides the problem of text orientation that is momentarily being solved, I am wondering why it is possible to style outsidetextfont but not possible to actually place text outside the chart (at least for the last level). Similarly to pie charts, I would expect to find a textposition = 'outside' parameter. At the moment, for tiny wedges, the labels are being squeezed in no matter what, ignoring the font sizes given in insidetextfont AND textfont. Example:

import plotly.graph_objects as go
data = pd.DataFrame.from_dict({'key': {0: '#iii',
  1: '#vi',
  2: 'I',
  3: 'III',
  4: 'V',
  5: 'bII',
  6: 'i',
  7: 'ii',
  8: 'iii',
  9: 'iv',
  10: 'v',
  11: 'major',
  12: 'minor'},
 'duration': {0: 4.0,
  1: 12.0,
  2: 85.0,
  3: 202.0,
  4: 4.0,
  5: 4.5,
  6: 655.0,
  7: 5.0,
  8: 4.0,
  9: 33.5,
  10: 54.5,
  11: 295.5,
  12: 768.0},
 'parent': {0: 'minor',
  1: 'minor',
  2: 'major',
  3: 'major',
  4: 'major',
  5: 'major',
  6: 'minor',
  7: 'minor',
  8: 'minor',
  9: 'minor',
  10: 'minor',
  11: '',
  12: ''}})
fig =go.Figure(go.Sunburst(
    labels=data.key,
    parents=data.parent,
    values=data.duration,
    branchvalues="total", 
    textfont = {'size': 20},
    insidetextfont = {'size': 20},
    textinfo = "label+percent parent",
    #textposition='outside' <-- this option is missing
    ))
fig.show()

sunburst

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Python reproduction with go.Sunburst and compare its label placement and font-size behavior with the pie-chart behavior mentioned in the issue. Trace the sunburst label options and determine the expected behavior for outside placement, tiny wedges, and textfont/insidetextfont; done means the requested option and sizing behavior work in the reported example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.