简体   繁体   English

散景图显示y轴标签/刻度中的间距不相等

[英]bokeh plottng figure shows unequal spacing in y axis labels/ticks

Am trying to plot a bokheh.plotting figure for my data that has categorical values. 我正在尝试为具有分类值的数据绘制一个bokheh.plotting图。 The plot does appear to come alright, however the y-axes is seen randomly spaced. 该图看起来确实不错,但是可以看到y轴是随机分布的。 Also some y-ticks are coming in bold ? 还有一些y标记会以粗体显示吗? I am attaching the figure and the code for your reference: 我附上该图和代码供您参考:

 from bokeh.plotting import figure, output_file, show
 output_file("categorical.html")

 p = figure(y_range = y, plot_width=800, plot_height=800)

 p.circle(x, y, size=sizes*3, fill_color = 'white', line_color="green", 
        line_width=2, legend = "abc")
 p.circle(x_1, y_1, size = sizes_1**2, fill_color = 
        'white',line_color="yellow", line_width=2,legend = "def")
 p.circle(x_2, y_2, size = sizes_2**2, fill_color = 'white', 
        line_color="blue", line_width=2,legend = "pqr")
 p.circle(x_3, y_3, size = sizes_3**2, fill_color = 'white', 
        line_color="black", line_width=2,legend = "xyz")
 p.circle(x_4, y_4, size = sizes_4**2, fill_color = 
        'white',line_color="red", line_width=2,legend = "fgh")
 p.circle(x_5, y_5, size = sizes_5**2, fill_color = 
          'white',line_color="brown", line_width=2,legend = "tyu")
 p.circle(x_6, y_6, size = sizes_6**2, fill_color = 
      'white',line_color="violet", line_width=2,legend = "qwe")

show(p)

Small sample snippets of my x,y: 我的x,y的小样本片段:

  x = abcd[abcd['PRODUCT'] == 'STRUCTURED']['RI'].tolist()
  y = abcd[abcd['PRODUCT'] == 'STRUCTURED']
                                 ['CODE'].tolist()
   sizes = abcd[abcd['PRODUCT'] == 'STRUCTURED']
                                   ['logabs'].values

在此处输入图片说明

The issue was the way p=figure(y_range = y) was defined. 问题是定义p=figure(y_range = y)

y_range should be unique list. y_range应该是唯一列表。

So 所以

y_list =  pd.unique(abcd['CCY_CODE']).tolist()
Then p = figure(y_range = y_list , plot_width=1010, plot_height=800)

This helped. 这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM