FactorRange only show 10 labels

I have grid layout, that I am coloring each tile in depending on the data value. I want some labels on the axis. The Problem is, that I have more than 100 x 100 points, and in any figure size I am interested in, the labels stack on top of each other and are not readable. Because they are in a order and I got the hover tool for each tile with the name, I would like to only show a few of the labels, so they stay readable.

Categorical factors are completely arbitrary, so in general there is way for Bokeh to assume which factors are “acceptable” to skip. that’s knowledge only the user has.

If you don’t actually care which ones get skipped, can you adapt the plot to use integer index values instead of categories? Then you could use a CusomJSTickFormatter to show the “string” axis labels instead o f the index values, but you would get the “nice” ticking that basic numeric axes have for free. If that’s an option I can describe in a bit more detail, if necessary.

If that’s not an option, then I think you will need custom ticker extension. I know there is an old StackOverflow post I can dig up.

That sounds like a solution for me. A little bit more detail would be great.
One additional question, which would be a nice to have: Is it possible, to formatt the ticks in a way, so that more labels are shown when zooming into the graphik? Or would that be something I have to specify manually using the update methods?

Well, let’s proceed in steps. First update your plot to use an integer index. Assuming your data is in a data frame, there might already be one. If not, you can create a CDS column with something like list(range(len(some_column))) (or np.arange would work too). Then create another CDS column that has all the axis labels in order for each row. Delete the factor range from the plot, and use the integer index for the y-coordinates of the glyph.

Once that is done we can move on to a js tick formatter.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.