tickvals and ticktext don't work with subcategory axes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
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:
tickvalsandticktextwork fine with a multi-category plotsshowticklabelsshould accept a list of booleans, .e.g.[True, False]to be able to hide a given subcategory if this is a multi-category plot
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the single-category and multi-category examples in the issue and compare the resulting axis behavior. Trace how multi-category axes process xaxis.tickvals, ticktext, and showticklabels; done means tickvals and ticktext work for multi-category plots and individual category labels can be hidden.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100