从多级FactorRange控制刻度标签 [英] Control tick-labels from multi-level FactorRange

查看:29
本文介绍了从多级FactorRange控制刻度标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个三层的 bokeh.models.FactorRange ,它用于在vbar绘图上绘制刻度标签.问题在于总共有数十种因素,最低级别的标签变得局促.

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.

我可以使用 plot.xaxis.formatter = bokeh.models.PrintfTickFormatter(format ='')来抑制绘制最低级别的标签,但这似乎是一个丑陋的hack.另外,我需要旋转第二级刻度标签,但是 plot.xaxis.major_label_orientation = ... 仅会影响最低级的刻度(就像 plot.xaxis.formatter 可以).

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).

如何分别控制 bokeh.models.FactorRange 的每个级别?

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

推荐答案

从Bokeh 0.12.13 开始,无法控制各个方向或不同级别的格式.

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.

出于完整性考虑,我将提到Bokeh是可扩展的,因此从技术上讲,始终可以创建自定义扩展.轴是Bokeh中最复杂的代码,完全自定义的Axis编写起来并不容易.但是,有可能足以成为 CategoricalAxis 的子类并仅覆盖此方法:

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

那是当前硬编码的'parallel'方向所在的位置,也是可以覆盖格式的位置.

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

这篇关于从多级FactorRange控制刻度标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆