I'm trying to add two step plots to the same Bokeh plot. Each step plot has different x values though, so the Step
function in the bkcharts
package doesnt work. I wanted to overlay two single Step
charts produced by the bkcharts
package, but it seems that you can't create a step chart with holoviews
. Is there an easy workaround?
import bokeh.plotting as bk
from bokeh.charts import Step
import pandas as pd
data1 = pd.DataFrame({'time': [1,3,5,7], 'value': [3,4,1,3]})
data2 = pd.DataFrame({'time': [2,4,6,9], 'value': [2,1,4,2]})
step1 = Step(data1, x='time', y='value')
step2 = Step(data2, x='time', y='value')
bk.show(Step(data1, x='time', y='value'))
bk.show(Step(data2, x='time', y='value'))
I would like to do something like step1 * step2
HoloViews does let you do a step chart, using options to the Curve element. See the example in the Gallery:
%%opts Curve [width=600] NdOverlay [legend_position='right']
hv.NdOverlay({interp: hv.Curve(points[::8])(plot=dict(interpolation=interp))
for interp in ['linear', 'steps-mid', 'steps-pre', 'steps-post']})
You can do the same with a regular Overlay (the *
operator) too; the key is to set the interpolation
option to one of the available types of steps.