Ozgur
Ozgur

Reputation: 172

View bar graphic with holoviews

I am trying to view a bar graph by using holoviews. Simply I worote this code below.

import numpy as np
import holoviews as hv
hv.extension('bokeh')

data = [('one',8),('two', 10), ('three', 16), ('four', 8), ('five', 4), 
('six', 1)]
bars = hv.Bars(data, hv.Dimension('Car occupants'), 'Count')

print(bars)

On jupyter notebook it works. Does holoviews work only with jupyter notebook? If not, what should I do to view it on shell?

Upvotes: 1

Views: 519

Answers (1)

James A. Bednar
James A. Bednar

Reputation: 3255

HoloViews supports Jupyter Notebooks and uses them extensively for its examples, because the notebook format allows output to be shown alongside the code that produced it. But if what you want to work with the output directly, you can e.g. render it to an HTML file:

import numpy as np, holoviews as hv
hv.extension('bokeh')

data = [('one',8),('two', 10), ('three', 16), ('four', 8), ('five', 4), ('six', 1)]
bars = hv.Bars(data, hv.Dimension('Car occupants'), 'Count')

renderer = hv.renderer('bokeh')
renderer.save(bars, 'output')

You can then load output.html into your web browser. See Plots and Renderers and Deploying Bokeh Apps for more options, including rendering to PNG or running live standalone servers.

Upvotes: 2

Related Questions