Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Comments

  1. DataFrame.hvplot (via the Python package hvplot) is the most convenient way to use HoloViews.

  2. If you want to use HoloViews directly, it is better to create a HoloViews.Dataset object and use it for visualization.

  3. The groupby option generates a plot with a dropdown list for interactively showing plots of different groups. You can overlay plots of different groups together on the same plot simplify by calling the .overlay() method.

!curl -sSL www.legendu.net/media/data/iris.csv -o iris.csv
import pandas as pd
iris = pd.read_csv("iris.csv")
iris.head()
Loading...

Use the hvplot Library

import holoviews as hv

# import hvplot
import hvplot.pandas

# hv.extension("bokeh")
Loading...
Loading...
Loading...
Loading...
fig = iris.hvplot.scatter("sepal_width_cm", "sepal_length_cm")
fig
Loading...
type(fig)
holoviews.element.chart.Scatter
iris.hvplot.scatter("sepal_width_cm", "sepal_length_cm", groupby="species")
Loading...
iris.hvplot.scatter("sepal_width_cm", "sepal_length_cm", groupby="species").overlay()
Loading...
iris.hvplot.scatter("petal_width_cm", "petal_length_cm", groupby="species").overlay()
Loading...

Use The HoloViews Library Directly

Pass a tuple (of x and y) to HoloViews.Scatter. You have to manually specify the labels for x and y-axis, otherwise, the default lables x and y will be used.

%%opts Scatter [width=600 height=500 tools=["hover"]]

hv.Scatter((iris.sepal_width_cm, iris.sepal_length_cm)).opts(xlabel="Sepal Width", ylabel="Sepal Length")
Loading...
%%opts Scatter [width=600 height=500 tools=['hover']]

hv.Scatter(iris, kdims="sepal_width_cm", vdims="sepal_length_cm")
Loading...

Use Dataset In The HoloViews Library

%%opts Scatter [width=600 height=500 tools=["hover"]]
hv.Scatter(iris, kdims=["sepal_width_cm", "species"], vdims=["sepal_length_cm"])
WARNING:param.Scatter: Chart elements should only be supplied a single kdim
Loading...
hv.Dataset(iris).to.scatter("sepal_width_cm", "sepal_length_cm", groupby=[])
Loading...
hv.Dataset(iris).to.scatter("sepal_width_cm", "sepal_length_cm", groupby="species")
Loading...
%%opts Scatter [width=600 height=500]

hv.Dataset(iris).to.scatter("sepal_width_cm", "sepal_length_cm", groupby="species").overlay()
Loading...