分类xaxis没有显示散景中的数字

时间:2022-01-07 00:36:07

My xaxis is formed out of a range (0,100). Instead of showing the numbers I would like to show a text, like "item1" every let's say 20 ticks. So instead of the first 20 ticks it should be "item1", instead of the following 20 - "item2" etc.

我的x轴是由一个范围(0,100)组成的。而不是显示我希望显示文本的数字,比如“item1”,每个让我们说20个滴答。因此,不是前20个刻度,它应该是“item1”,而不是以下20个 - “item2”等。

x=range(0,100)
y=[5 for i in x]
p = figure()
p.circle(x=x, y=y)
show(p)

分类xaxis没有显示散景中的数字

What I would like is instead of 0,20,40 etc. to have the items of a list: categorical=["item1","item2","item3","item4","item5"] and do not show the numbers at all.

我想要的是代替0,20,40等以获得列表的项目:分类= [“item1”,“item2”,“item3”,“item4”,“item5”]并且不显示完全没有数字。

I've tried with p = figure(x_range=categorical) but then not all the dots appear - only 1 per category appears.

我试过p = figure(x_range =分类),但不是所有的点都出现 - 每个类别只出现1个。

I've also tried with factors:

我也试过了因素:

factors = [("item1", 1), ("item1", 2) ....("item2", 21)... ]
x_range = FactorRange(*factors)

But then all the numbers appear and it ends up with something like this if you have more than 1000 numbers: 分类xaxis没有显示散景中的数字

但是,如果你有超过1000个数字,那么所有数字都会出现,最终会出现这样的结果:

1 个解决方案

#1


0  

I did it with:

我做到了:

p.xaxis.major_label_overrides = {0: "type1", "20": "type2"...}
p.xaxis[0].ticker = FixedTicker(ticks=[0, 20 ...])

#1


0  

I did it with:

我做到了:

p.xaxis.major_label_overrides = {0: "type1", "20": "type2"...}
p.xaxis[0].ticker = FixedTicker(ticks=[0, 20 ...])