pythonbokehholoviews

Using Holoviews, how can I set a title?


I have been trying to set a title when using Holoviews and Bokeh. I'm overlaying 3 plots on each other. The code looks like this:

%%opts Curve [width=900 height=400  show_grid=True tools=['hover'] finalize_hooks=[apply_formatter]]
%%opts Curve (color=Cycle('Category20'))
%%opts Overlay [ legend_position='bottom' ] Curve (muted_alpha=0.5 muted_color='black' )

actual_curve = hv.Curve(df_reg_test, 'date', 'y', label='Actual')
existing_curve = hv.Curve(df_reg_test, 'date', 'Forecast Calls', label='Existing Forecast')
xgb_curve = hv.Curve(df_reg_test, 'date', 'xgb_pred', label='New Forecast')

actual_curve * existing_curve * xgb_curve

The plot looks like this: Holoview Plot

As you can see, the labels of the individual curves show up great in the legend, but I get no title at the top of the plot.

How can I manually just set a title?


Solution

  • I figured out that I can add a title_format="my new title" option in the overlay opts:

    %%opts Curve [width=900 height=400  show_grid=True tools=['hover'] finalize_hooks=[apply_formatter]]
    %%opts Curve (color=Cycle('Category20'))
    %%opts Overlay [ legend_position='bottom' title_format="my new title"] Curve (muted_alpha=0.5 muted_color='black' )
    
    actual_curve = hv.Curve(df_reg_test, 'date', 'y', label='Actual')
    existing_curve = hv.Curve(df_reg_test, 'date', 'Forecast Calls', label='Existing Forecast')
    xgb_curve = hv.Curve(df_reg_test, 'date', 'xgb_pred', label='New Forecast')
    
    actual_curve * existing_curve * xgb_curve
    

    Now my plot has a title:

    Holoviews Plot with Title