Holoviews color per category

后端 未结 2 2022
长情又很酷
长情又很酷 2021-01-20 15:32

I have been lately working with bokeh for plotting. I just found out about holoviews and wanted to plot a basic box plot.

In my box plot I am trying to color per on

2条回答
  •  一整个雨季
    2021-01-20 16:19

    Most Elements in HoloViews have a color_index plot option which allows coloring by a particular variable. Using your example here we color by the 'customer' variable and define a HoloViews Cycle for the box_color using the Set1 colormap.

    data = (np.random.randint(0, 3, 100), np.random.randint(0, 5, 100), np.random.rand(100))
    boxwhisker = hv.BoxWhisker(data, ['total_time', 'customer'], 'amount')
    plot_opts = dict(show_legend=False, width=800, height=400, color_index='customer')
    style_opts = dict(box_color=hv.Cycle('Set1'))
    boxwhisker.opts(plot=plot_opts, style=style_opts)
    

    If you want to define a custom set of colors you can also define an explicit Cycle like this: Cycle(values=['#ffffff', ...]).

提交回复
热议问题