Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Comments¶
DataFrame.hvplot(via the Python packagehvplot) is the most convenient way to use HoloViews.If you want to use HoloViews directly, it is better to create a HoloViews.Dataset object and use it for visualization.
The
groupbyoption 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.csvimport pandas as pdiris = 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")
figLoading...
type(fig)holoviews.element.chart.Scatteriris.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...