簡體   English   中英

Bokeh 在 Raspberry Pi 上找不到條形圖模塊

[英]Bokeh doesn't find Bar-chart modules on Raspberry Pi

_我正在嘗試使用散景制作條形圖以作為 .html 文件輸出。 通過簡單的繪圖,一切正常,但是由於某種原因,當我嘗試運行以下代碼時:

from bokeh.charts import Bar, output_file, show
from bokeh.sampledata.autompg import autompg as df

p = Bar(df, label='yr', values='mpg', agg='mean',
    title="Average MPG by YR")

output_file("bar.html")_

我最終得到一個錯誤說:

導入錯誤:沒有名為“bokeh.charts”的模塊

我已經通過 pip 安裝了 Pandas、Numpy,它們都可以使用 help('modules') 命令找到。 我知道 Pandas 是高級散景圖所必需的,並且它已通過 Pip 安裝

Pandas 版本:0.20.3 Bokeh 版本:0.12.9 Python 是 3.4.2 版

我也嘗試過不同的導入命令,“from bokeh import *”等,但似乎沒有任何效果。

除了Holoviews 之外,如果您只需要簡單的條形圖,這些現在也可以通過穩定的bokeh.plotting API輕松制作,例如:

group = df.groupby('cyl')
source = ColumnDataSource(group)

cyl_cmap = factor_cmap('cyl', palette=Spectral5, factors=sorted(df.cyl.unique()))

p = figure(plot_height=350, x_range=group, title="MPG by # Cylinders")

p.vbar(x='cyl', top='mpg_mean', width=1, source=source,
       line_color=cyl_cmap, fill_color=cyl_cmap)

在此處輸入圖片說明

bokeh.charts已被棄用 您可以通過安裝和導入 bkcharts 包來恢復該功能,但將來將不支持此功能。 散景開發人員建議檢查全息視圖(使用散景作為可能的后端)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM