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!

There are many ways to achievie groupby in HolovViews.

  1. Directly use the groupby method of HoloViews objects!!!

  2. Use the method HoloMap to create a dictionary of parameters to HoloViews objects.

  3. Use the method dataset.to which has groupby option. However, it seems to me that this doesn’t give me options to select which one to show. But with click and transparent parameters configured, you can achieve similar effect ...

  4. Use kdim

  5. Manually create a list of HoloViews object ...

  6. It seems that you can simplify call the overlay methods to convert a list or a map to overlayed plots!!!

import numpy as np
import pandas as pd
import holoviews as hv

hv.extension("bokeh")
Loading...
Loading...
Loading...
macro_df = pd.read_csv("http://assets.holoviews.org/macro.csv", "\t")
key_dimensions = [("year", "Year"), ("country", "Country")]
value_dimensions = [
    ("unem", "Unemployment"),
    ("capmob", "Capital Mobility"),
    ("gdp", "GDP Growth"),
    ("trade", "Trade"),
]
macro = hv.Table(macro_df, key_dimensions, value_dimensions)
%%opts Scatter [width=700 height=400 scaling_method='width' scaling_factor=2 size_index=2 show_grid=True] 
%%opts Scatter (color=Cycle('Category20') line_color='k')
%%opts NdOverlay [legend_position='left' show_frame=False]
gdp_unem_scatter = macro.to.scatter('Year', ['GDP Growth', 'Unemployment'])
gdp_unem_scatter.overlay('Country')
Loading...

Use groupby to generate a plot with droplist selections.

from bokeh.sampledata.iris import flowers

ds = hv.Dataset(flowers)
ds.to(hv.Points, ["petal_length", "petal_width"], groupby="species")
Loading...

Use the overlay method to place all objects on the same plot.

from bokeh.sampledata.iris import flowers

ds = hv.Dataset(flowers)
ds.to(hv.Points, ["petal_length", "petal_width"], groupby="species").overlay()
Loading...

Questions

How to specify the type (slider or droplist) for kdim?

HoloMap: hard to see everything on the same plot. Can I do it?

References

http://holoviews.org/reference/containers/bokeh/HoloMap.html

http://holoviews.org/user_guide/Dimensioned_Containers.html

http://holoviews.org/reference/containers/bokeh/HoloMap.html