2

“以前的版本”问题与将Bokeh 更新到 0.5.0 中所述的问题相同,现在在一个窗口中绘制所有以前版本的图形。我在 iPython 笔记本中运行它;每次我重新运行单元格时,输出的 html 文件都会显示所有以前的版本,以及新版本。

另一个问题是我无法在输出文件中指定绘图的大小和/或纵横比。

这是整个脚本:

x = [0.4, 0.6, 0.8, 0.5]
y = [0.8, 0.5, 0.8, 0.9]
import bokeh.plotting as bplt
bplt.output_file('output.html')
bplt.figure(tools="wheel_zoom", width=1000, height=3000)
bplt.hold()
bplt.circle(x, y, color='red', 
       line_color='black', fill_alpha = 0.8, size = 10,
       title = 'Ternary plot', background_fill='#dddddd')
bplt.line(x=[0,0.5],y=[1,0.134])
bplt.line(x=[0.5,1],y=[0.134,1])
bplt.line(x=[1,0],y=[1,1])
bplt.show()

无论我为宽度和高度设置什么值,输出始终是相同的大小和纵横比。

4

1 回答 1

1

width并且height必须从字形函数(如circle等)中删除作为设置绘图宽度和高度的选项,因为某些字形也具有它们自己widthheight属性并且存在冲突。但是,它可能应该作为 and 的别名保留在调用figure中。我添加了一张票以将这些恢复为别名:plot_widthplot_heightfigure

https://github.com/ContinuumIO/bokeh/issues/897

同时,您可以传递plot_widthplot_height传递figure(...),它会按照您想要的方式调整绘图大小。

如果要清除plotting.py会话状态,reset_output()则在 0.5.1 中添加。这是一个完整的工作脚本:

x = [0.4, 0.6, 0.8, 0.5]
y = [0.8, 0.5, 0.8, 0.9]
import bokeh.plotting as bplt
bplt.reset_output()
bplt.output_file('output.html')
bplt.figure(tools="wheel_zoom", plot_width=100, plot_height=300)
bplt.hold()
bplt.circle(x, y, color='red', 
   line_color='black', fill_alpha = 0.8, size = 10,
   title = 'Ternary plot', background_fill='#dddddd')
bplt.line(x=[0,0.5],y=[1,0.134])
bplt.line(x=[0.5,1],y=[0.134,1])
bplt.line(x=[1,0],y=[1,1])
bplt.show()
于 2014-07-26T04:43:07.013 回答