ipython - 将绘图拟合到绘图窗口中

标签 ipython jupyter-notebook bokeh

我自己做了一个直方图,每个条形的总和是1。所以每个条形都小于1。为什么它们不适合绘图窗口?我怎样才能实现这个目标?

yaxis().bounds = [0,1]

这仅设置轴,但不适合我的绘图。没有适当的 Bokeh 文档吗,我对这么简单的问题很生气。

from bokeh.plotting import *
from __future__ import division
output_notebook()
from bokeh.plotting import rect

balkenbreite = 5
mitten = [10,20,30,40]
werte = [10,15,10,5]
anteil = []
sumVal = sum(werte)
for i in range(len(werte)):
    anteil.append(0)
for i in range(len(anteil)):
    anteil[i] = werte[i]/sumVal
print anteil

figure()
hold(False)
rect([mitten[0]],[anteil[0]/2], width=balkenbreite, height=anteil[0], plot_width=400, color = "#ff1200", plot_height=400, tools="pan")
hold(True)
for i in range(len(mitten)):
    if i==0: continue
    rect([mitten[i]],[anteil[i]/2], width=balkenbreite, height=anteil[i], plot_width=400, color = "#ff1200", plot_height=400)
xaxis()[0].axis_label="Areas"
yaxis()[0].axis_label="Frequency"
yaxis()[0].bounds = [0,1]
show()

enter image description here

最佳答案

注释(2014 年 4 月 8 日):Bokeh仍处于早期但积极的开发阶段,因此暂时会出现此类问题。我们希望在继续扩展文档的同时尽快回答这些问题,但与此同时您可能会找到 tutorials提供帮助。

对于手头的问题:当前绘图范围可以使用 Range1d 设置对象,该对象被分配给 x_rangey_range 关键字参数。这些可以在 figure() 实例上设置。

这三行应该可以解决问题:

from bokeh.objects import Range1d
yr = Range1d(start=0, end=1)
figure(y_range=yr)

编辑:这是我想象你想要的屏幕截图。

Screenshot

关于ipython - 将绘图拟合到绘图窗口中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22936499/

相关文章:

python - 无法在 Pandas 中读取 Excel 文件

visual-studio-code - VS Code 和 Jupyter Notebook - 如何在文本编辑器中打开大输出?

python - 数据框中几个属性的数据描述

python - 在 ipython 笔记本上找不到模块

python - 带和不带笔记本的 IPython 差异

Python - 发生意外导入

python - PreviewSavetool 和 BoxSelectionOverlay 的 Bokeh 工具导入错误

python - ImportError : libgeos-3. 6.2.so:无法打开共享对象文件:没有这样的文件或目录

jupyter-notebook - Altair 保护程序 ValueError : Unsupported format: 'png'

python - Bokeh 或 Plotly 中的极坐标图