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=Tr
Solution 1:
Another way of adding a general title to your Overlay is by using:
opts.Overlay(title='New title for Overlay')
Here's an example of setting a title on your Holoview Overlay plot:
# import libraries
import numpy as np
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')
# create some sample data
data1 = np.random.normal(size=[50, 2])
data2 = np.random.normal(size=[50, 2])
# create your overlay plot
all_plots = hv.Scatter(data1, label='data1') * hv.Scatter(data2, label='data2')
# add your title to your overlay with opts.Overlay()
all_plots.opts(opts.Overlay(title='New title for Overlay'))
The resulting plot will look like this:
Solution 2:
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:
Post a Comment for "Using Holoviews, How Can I Set A Title?"