Yin*_*iao 3 holoviews google-colaboratory
我尝试了所有三个后端,但没有显示任何图表。一个例子是:
!pip install -q holoviews
import holoviews as hv
from holoviews import opts
hv.extension('matplotlib')
# build a dataset where multiple columns measure the same thing
stamp = [.33, .33, .34, .37, .37, .37, .37, .39, .41, .42,
.44, .44, .44, .45, .46, .49, .49]
postcard = [.20, .20, .21, .23, .23, .23, .23, .24, .26, .27,
.28, .28, .29, .32, .33, .34, .35]
group = "U.S. Postage Rates (1999-2015)"
stamp = hv.Curve(stamp, vdims='Rate per ounce', label='stamp', group=group)
postcard = hv.Curve(postcard, vdims='Rate per ounce', label='postcard', group=group)
postage = (stamp * postcard)
postage.opts(
opts.Curve(interpolation='steps-mid', linestyle=hv.Cycle(values=['--', '-'])),
opts.Overlay(legend_position='top_left'))
Run Code Online (Sandbox Code Playgroud)
代码可以运行,但不会在结果中绘制任何图形。
您需要在 Jupyter 笔记本之外使用 matplotlib 渲染器,具体操作如下:mr = hv.renderer('matplotlib') mr.show(curve)
工作版本:https : //colab.research.google.com/drive/1CrfBZsTzYjf3NpwQJ1VwjQ_Eq1cjMBpe
!pip install -q holoviews
import holoviews as hv
from holoviews import opts
hv.extension('matplotlib')
# build a dataset where multiple columns measure the same thing
stamp = [.33, .33, .34, .37, .37, .37, .37, .39, .41, .42,
.44, .44, .44, .45, .46, .49, .49]
postcard = [.20, .20, .21, .23, .23, .23, .23, .24, .26, .27,
.28, .28, .29, .32, .33, .34, .35]
group = "U.S. Postage Rates (1999-2015)"
stamp = hv.Curve(stamp, vdims='Rate per ounce', label='stamp', group=group)
postcard = hv.Curve(postcard, vdims='Rate per ounce', label='postcard', group=group)
postage = (stamp * postcard)
postage.opts(
opts.Curve(interpolation='steps-mid', linestyle=hv.Cycle(values=['--', '-'])),
opts.Overlay(legend_position='top_left'))
mr = hv.renderer('matplotlib')
mr.show(postage)
Run Code Online (Sandbox Code Playgroud)
散景:
import numpy as np
from bokeh.plotting import figure, show
from bokeh.io import output_notebook
hv.extension('bokeh')
output_notebook()
plot = figure(y_axis_label=("U.S. Postage Rates (1999-2015)"), plot_width=300, plot_height=300)
plot.step(x=list(range(0, 17)), y=[.20, .20, .21, .23, .23, .23, .23, .24, .26, .27,
.28, .28, .29, .32, .33, .34, .35], color="#FB8072")
show(plot)
Run Code Online (Sandbox Code Playgroud)
调用一次
%env HV_DOC_HTML=true
Run Code Online (Sandbox Code Playgroud)
然后,在每个单元格中。
hv.extension('bokeh')
Run Code Online (Sandbox Code Playgroud)
改编自 @james-a-bednar 的这个答案
| 归档时间: |
|
| 查看次数: |
1942 次 |
| 最近记录: |