plotly.js icon indicating copy to clipboard operation
plotly.js copied to clipboard

Multicategory -- display only category label on axis

Open aamster opened this issue 6 years ago • 8 comments

I would like to display only the category, and not the specific tick labels on the axis. For example, in this example https://codepen.io/plotly/pen/bOByWR I would like to only display 'SF Zoo' and 'LA Zoo'. I've tried several hacks such as setting tick labels to empty string, but in my case the plot still leaves room for the tick labels and it looks weird. See what I mean: image

Is there a way to accomplish this? I think I might have to use the idea of subcategory axis instead.

aamster avatar May 21 '19 16:05 aamster

I was able to do it by setting the tick labels to be different length empty strings and then rotating ticklabels 0 degrees.

aamster avatar May 21 '19 18:05 aamster

Hi @aamster Thanks for writing in!

Can I ask why you're trying to plot your data on a multicategory axis if you only want to see one category level?

etpinard avatar May 21 '19 20:05 etpinard

We could certainly add an attribute named e.g. hideinnerlabels:false to do what you're requesting, but more context would help us make an informed decision.

Thanks again!

etpinard avatar May 21 '19 20:05 etpinard

@etpinard I essentially wanted a single category label to span multiple ticks, since there are too many individual tick labels to display. I can then hover over each individual bar to see what that bar represents. Here's a truncated finished version:

Screenshot from 2019-05-21 17-01-54

aamster avatar May 21 '19 21:05 aamster

Thanks for replying!

Have you tried using tickvals and ticktext as in https://codepen.io/etpinard/pen/mYqjVP ?

etpinard avatar May 21 '19 21:05 etpinard

@etpinard that's interesting but you still have to set empty string to all but one of ticktext and then set the middle ticktext to the category value. It's still better than my solution I think.

aamster avatar May 21 '19 21:05 aamster

@aamster right by codepen was meant to be a workaround.

I agree something is missing from our current multicategory implementation. Maybe a new boolean (e.g. hideinnerlabels:false, but how would that work with https://github.com/plotly/plotly.js/issues/2175) or maybe we should extend tickext and tickvals to multicategory axes.

I'll tag your ticket under type: feature. Thanks very much for posting!

etpinard avatar May 21 '19 22:05 etpinard

please add this feature

willleeney avatar Sep 21 '22 18:09 willleeney