如何调整散景轴上的刻度数(小数字上的标签重叠) [英] how to adjust # of ticks on Bokeh axis (labels are overlapping on small figures)

查看:104
本文介绍了如何调整散景轴上的刻度数(小数字上的标签重叠)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个垂直堆积&的多图散景图.对齐的数字.因为我想垂直对齐图,所以将y轴标签旋转为垂直而不是水平.

I have a multi-figure Bokeh plot of vertically stacked & aligned figures. Because I want to align the plots vertically, the y-axis labels are rotated to be vertical rather than horizontal.

在某些情况下,Bokeh产生过多的滴答声,使得滴答声标签完全重叠,难以辨认.这是一个示例:

In certain scenarios, Bokeh produces too many ticks, such that the tick labels overlap completely, making illegible. Here is an example:

import bokeh.plotting as bp
import numpy as np

y = np.random.uniform(0, 300, 50)
x = np.arange(len(y))

bp.output_file("/tmp/test.html", "test")
plot = bp.figure(plot_width=800, plot_height=200)
plot.yaxis.axis_label_text_font_size = "12pt"
plot.yaxis.major_label_orientation = 'vertical'

plot.line (x,y)
bp.show(plot)

使渲染器足够聪明以自动产生更少的标签的短暂时间,是否有办法指示要在轴上放置的标签数量?

Short of making the renderer clever enough to produce fewer labels automatically, is there a way to indicate the # of labels to be placed on an axis?

就其对10的幂的亲和力而言,似乎生成的标签数量与数据范围有关.

It seems that the # of labels generated has to do with the range of the data, in terms of its affinity to a power of 10.

推荐答案

似乎仍然没有直接的方法来指定此名称.请遵循相关的问题.这是一种解决方法:

Looks like there is still no direct way to specify this. Please follow the related issue. This is a workaround:

from bokeh.models import SingleIntervalTicker, LinearAxis

plot = bp.figure(plot_width=800, plot_height=200, x_axis_type=None)
ticker = SingleIntervalTicker(interval=5, num_minor_ticks=10)
xaxis = LinearAxis(ticker=ticker)
plot.add_layout(xaxis, 'below')

您可以通过SingleIntervalTicker中的interval参数控制票证的数量.

You can control the number of tickets via the interval parameter in SingleIntervalTicker.

这篇关于如何调整散景轴上的刻度数(小数字上的标签重叠)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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