我试图为具有分类值的数据绘制bokheh.plotting数字。 该图似乎没有问题,但y轴是随机分布的。还有一些y-ticks以粗体显示? 我附上了数字和代码供您参考:
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)
我的x,y的小样本片段:
x = abcd[abcd['PRODUCT'] == 'STRUCTURED']['RI'].tolist()
y = abcd[abcd['PRODUCT'] == 'STRUCTURED']
['CODE'].tolist()
sizes = abcd[abcd['PRODUCT'] == 'STRUCTURED']
['logabs'].values
答案 0 :(得分:0)
问题在于p=figure(y_range = y)
的定义方式。
y_range应该是唯一列表。
所以
y_list = pd.unique(abcd['CCY_CODE']).tolist()
Then p = figure(y_range = y_list , plot_width=1010, plot_height=800)
这有帮助。