Open
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:
tickvals
andticktext
work fine with a multi-category plotsshowticklabels
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