Search code examples
axisspacingholoviews

x-axis spacing in holoviews


Im currently plotting a bar graph and a curve with float intervals as months, displayed as 2012.083333, 2012.16666667 etc. etc. on the x-axis.

Im plotting a 4 year interval and want to increase the spacing between the months and cant find a solution in the holoviews documentation.

these are my options and object coding at the moment:

% output size = 250
% opts Curve (color='red')
% opts Curve.food (color='green')
%opts Curve (linewidth=3.0)
# holoviews objects 
bars = hv.Bars(data_inject1, "{}".format(country), 'normalised precipitation and temperature, product: {}'.format(product), label = 'precipitation')
line1 = hv.Curve(data_inject2, "{}".format(country), 'normalised precipitation and temperature, product: {}'.format(product),label = 'temperature')
line2 = hv.Curve(data_inject3, label = 'food')

# merge hv objects
plot = bars * line1 * line2

So the question is effectively, how do I increase the x-axis spacing? Kind regards, Take


Solution

  • Something like this?

    hv.Curve((np.arange(0, 10))).options(xticks=[0, 8])

    where xticks can be np.arange(2012, 2018, 1) or something.

    Curve xticks

    holoviews/bokeh/matplotlib also support datetime formatting if you don't want to deal with float intervals datetime xaxis