Python散景图四分类x轴不绘制字符串是否存在

时间:2016-01-27 11:13:34

标签: python figure bokeh quad

我有一个包含两列的数据框:<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ alert("Hello"); }); }); </script> x_att1y_att1包含int或float。如果y_att1包含数字作为字符串,那么我可以绘制x_att1。但如果y_att1包含字符串,则不会绘制任何内容。我不知道为什么。这是一个错误还是一个功能?我用散景0.10.0

代码1,数字为x_att1的字符串(有效):

x_att1

代码2,字符串位于from bokeh.plotting import figure, output_file, show from bokeh.models import LinearAxis, Range1d import pandas as pd output_file("bars.html") df = pd.DataFrame() df['y_att1'] = [0.70,0.68,0.50,0.48,0.30,0.28] df['x_att1'] = ['0','4','2','7','3','1'] p = figure(title="twin y-axis bar example", x_range=df['x_att1'].values.tolist()) p.quad(bottom=0, top=df['y_att1'], left=df['x_att1'].values.tolist() , right=df['x_att1'].values.tolist(), line_width=7, line_color='red') p.yaxis.axis_label = 'left y axis' p.yaxis.axis_label_text_color = 'red' p.xaxis.axis_label = 'x axis' p.xaxis.axis_label_standoff = -5 show(p) (不起作用):

x_att1

代码3包含from bokeh.plotting import figure, output_file, show from bokeh.models import LinearAxis, Range1d import pandas as pd output_file("bars.html") df = pd.DataFrame() df['y_att1'] = [0.70,0.68,0.50,0.48,0.30,0.28] df['x_att1'] = ['b','d','a','h','f','e'] #changed only this line p = figure(title="twin y-axis bar example", x_range=df['x_att1'].values.tolist()) p.quad(bottom=0, top=df['y_att1'], left=df['x_att1'].values.tolist() , right=df['x_att1'].values.tolist(), line_width=7, line_color='red') p.yaxis.axis_label = 'left y axis' p.yaxis.axis_label_text_color = 'red' p.xaxis.axis_label = 'x axis' p.xaxis.axis_label_standoff = -5 show(p) 的字符串和一些技巧(有效):

x_att1

美好的一天!

0 个答案:

没有答案