使用Holoviews,如何设置标题? [英] Using Holoviews, how can I set a title?

查看:172
本文介绍了使用Holoviews,如何设置标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用Holoviews和Bokeh设置标题.我正在彼此叠加3个地块.代码如下:

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:

如您所见,各个曲线的标签在图例中显示得很好,但是在图的顶部我没有标题.

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.

如何手动设置标题?

推荐答案

我发现可以在叠加选项中添加title_format ="my new title"选项:

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,如何设置标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆