I have Anaconda 3.7 installed on Windows. It works in Jupyter but not in Spyder. This code:
import holoviews as hv
import pandas as pd
import numpy as np
output_notebook ()
flora = pd.read_csv ('iris.csv')
hv.extension('bokeh')
frequencies, edges = np.histogram(flora['petal width'], bins = 5)
print(frequencies, edges)
hv.Histogram(frequencies, edges, label = 'Histogram')
returns only values:
[49 8 41 29 23] [0.1 0.58 1.06 1.54 2.02 2.5 ]
WARNING:root:Histogram: Histogram edges should be supplied as a tuple along with the values, passing the edges will be deprecated in holoviews 2.0.
Is it possible to see histogram in Spyder?
As a workaround, you can open your graph in your browser by putting your Holoviews graph in a Panel object and calling .show() on it.
Library Panel can be used to create a dashboard with Holoviews graphs in your browser.
Here's a working example:
# library imports
import numpy as np
import pandas as pd
import holoviews as hv
hv.extension('bokeh', logo=False)
import panel as pn
# create sample data
data = np.random.normal(size=[50, 2])
df = pd.DataFrame(data, columns=['col1', 'col2'])
# create holoviews graph
hv_plot = hv.Points(df)
# display graph in browser
# a bokeh server is automatically started
bokeh_server = pn.Row(hv_plot).show(port=12345)
# stop the bokeh server (when needed)
bokeh_server.stop()
See also:
https://stackoverflow.com/questions/57971107/how-do-i-get-my-interactive-holoviews-graph-to-display-in-visual-studio-without/[][1]
Alternatively you can set bokeh as backend of the renderer and then use bokeh.render.show(). This will open your holoviews plot in the browser:
import holoviews as hv
hv.extension('bokeh')
from bokeh.plotting import show
show(hv.render(your_holoviews_plot))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With