import numpy as np import pandas as pd 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') bars bars[['one', 'two', 'three']] + bars[['four', 'five', 'six']] occupants = hv.Dimension('Car occupants', values=['three', 'two', 'four', 'one', 'five', 'six']) # or using .redim.values(**{'Car Occupants': ['three', 'two', 'four', 'one', 'five', 'six']}) hv.Bars(data, occupants, 'Count') samples = 100 pets = ['Cat', 'Dog', 'Hamster', 'Rabbit'] genders = ['Female', 'Male'] pets_sample = np.random.choice(pets, samples) gender_sample = np.random.choice(genders, samples) count = np.random.randint(1, 5, size=samples) df = pd.DataFrame({'Pets': pets_sample, 'Gender': gender_sample, 'Count': count}) df.head(2) bars = hv.Bars(df, kdims=['Pets', 'Gender']).aggregate(function=np.sum) bars.opts(width=500) bars.redim.values(Pets=pets, Gender=genders) + bars.sort() bars.sort() + bars.clone().opts(multi_level=False) bars.opts(stacked=True)