import numpy as np import holoviews as hv from holoviews import dim hv.extension('matplotlib') hv.Rectangles([(0, 0, 1, 1), (2, 3, 4, 6), (0.5, 2, 1.5, 4), (2, 1, 3.5, 2.5)]) hv.Rectangles([(0, 0, 1, 1, 1), (2, 3, 4, 6, 2), (0.5, 2, 1.5, 4, 3), (2, 1, 3.5, 2.5, 4)], vdims='value').opts(color='value') xs = np.arange(100) ys = np.random.randn(101).cumsum() O = ys[1:] C = ys[:-1] H = np.max([O, C], axis=0) + np.random.rand(100) L = np.min([O, C], axis=0) - np.random.rand(100) boxes = hv.Rectangles((xs-0.25, O, xs+0.25, C)) segments = hv.Segments((xs, L, xs, H)) # Color boxes where price decreased red and where price increased green color_exp = (dim('y0')>dim('y1')).categorize({True: 'green', False: 'red'}) boxes.opts(aspect=3, fig_size=500, color=color_exp, xlabel='Time', ylabel='Price') * segments.opts(color='black')