简体   繁体   English

在Bokeh python中更改工具提示颜色的正确方法是什么?

[英]What is the right way to change the color of a tooltip in Bokeh python?

Objective : To learn how to change the background color of Bokeh tooltip in Python. 目的 :了解如何在Python中更改Bokeh工具提示的背景颜色。

Below is the code that works for me, but I cannot seem to adjust the color within the tooltip (currently this produces only a white background for the tooltip/hover): 以下是对我有用的代码,但我似乎无法调整工具提示中的颜色(当前,工具提示/悬停只产生白色背景):

# Sometimes Bokeh is to verbose
import warnings
warnings.filterwarnings('ignore')

# Develop a histogram
from bokeh.charts import Bar, output_file, show

# Information contained within the hoover
tooltips=[
    ('Age', '@Age'),
    ('Count', '@height{0,000}')
]


colormap = {'Age':'gray'}
colors = colormap

from bokeh.palettes import brewer
#palette = brewer["Blues"][3]

# Create chart
p = Bar(data, 'Age', values='Age', title="Hep-C Age",xlabel="Age", ylabel="Number of Observations",
        agg='count',
       tooltips=tooltips, legend=False,plot_width=600, plot_height=400, 
        tools="lasso_select,box_select,tap,box_zoom,reset,save", active_drag="lasso_select",
       toolbar_location="above",color="gray",title_text_font_size='14pt',title_text_color="gray")

Based on Alex I successfully found a solution: 基于亚历克斯,我成功找到了一个解决方案:

hover = HoverTool( tooltips="""

    <div style ="border-style: solid;border-width: 15px;background-color:black;">         
        <div>
            <span style="font-size: 12px; color: white;font-family:century gothic;">@height{0,000}</span>
            <span style="font-size: 12px; color: white;font-family:century gothic;"> Observations</span>
        </div>
    </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM