Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control tick-labels from multi-level FactorRange

Tags:

python

bokeh

I've got a three-level bokeh.models.FactorRange which I use to draw tick labels on a vbar-plot. The problem is that there are dozens of factors in total and the lowest-level labels get very cramped.

I can use plot.xaxis.formatter = bokeh.models.PrintfTickFormatter(format='') to suppress drawing of the lowest-level labels, but this seems like an ugly hack. Also, I need to have the second-level tick labels to be rotated, yet plot.xaxis.major_label_orientation = ... only ever affects the lowest-level ticks (just like plot.xaxis.formatter does).

How to control each level of bokeh.models.FactorRange individually?

like image 597
user2722968 Avatar asked Jan 10 '18 15:01

user2722968


People also ask

What is a Matplotlib tick and tick label?

Ticks are the markers denoting data points on the axes and tick labels are the name given to ticks. By default matplotlib itself marks the data points on the axes but it has also provided us with setting their own axes having ticks and tick labels of their choice. Attention geek!

What are the default labels for tick marks in R?

labels : labels of axis tick marks. Allowed values are : trans for axis transformations. Possible values are “log2”, “log10”, “sqrt”, etc The R code below set the position of tick marks on the y axis of the box plot.

What is the difference between a tick and a tick label?

Ticks are the markers denoting data points on the axes and tick labels are the name given to ticks. By default matplotlib itself marks the data points on the axes but it has also provided us with setting their own axes having ticks and tick labels of their choice.

How to change the appearance of the Axis tick mark labels?

Change the appearance of the axis tick mark labels The color, the font size and the font face of axis tick mark labels can be changed using the functions theme () and element_text () as follow : p + theme(axis.text.x= element_text(family, face, colour, size)) p + theme(axis.text.y = element_text(family, face, colour, size))


1 Answers

As of Bokeh 0.12.13, there is no way to control the individual orientations or formatting of different levels.

The basic initial work to revamp categorical support (for multi-level axes, etc) was a large update. Rather than add more even complexity and risk up front for features we were not sure anyone would want or need, we started with basic capability, expecting to hear from users in time what additional features were justified. This seems like it has come up a few times, so it would be reasonable to consider adding, but it would represent new work, so a GitHub feature request issue is the appropriate next step.

For completeness, I will mention that Bokeh is extensible, so it's always technically possible to create a Custom Extension. Axes are some of the most complicated code in Bokeh, and a full custom Axis would be non-trivial to write. However it's possible that would be sufficient to make subclass of CategoricalAxis and just override this one method:

https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/axes/categorical_axis.ts#L83-L110

That's where the currently hard-coded 'parallel' orientation are, and also where formatting could be overridden.

like image 107
bigreddot Avatar answered Oct 23 '22 02:10

bigreddot