Search code examples
pythonbokehpanelpandas-bokehholoviz-panel

Implement a colored frame around graph tiles (panel bokeh) (holoViz bokeh)


How can I let bokeh draw a colored border (frame) around the graph tile? Some graph tiles have to be graphically highlighted against the other graphs and the customer therefore wants to have a colored border / colored frame around some graph tiles. Unfortunately, I did not find anything to it in the documentation on Holoviz bokeh.

Is this even possible?

Thanks in advance. Best regards


Solution

  • You can add a border around a title by updating the Title annotation manually, or creating a new one and adding it to your Figure.

    from bokeh.io import show
    from bokeh.models.annotations import Title
    from bokeh.plotting import figure
    from bokeh.layouts import row
    
    # Use your own Title annotation
    p1 = figure(height=250, width=400)
    p1.line([0, 1, 2, 3], [0, 2, 1, 3])
    p1.title = Title(
        text='hello world!', text_font_size='16pt', 
        border_line_color='red', border_line_width=3
    )
    
    # OR configure the existing one:
    p2 = figure(height=250, width=400)
    p2.line([0, 1, 2, 3], [0, 2, 1, 3])
    p2.title.text = 'hello world again!'
    p2.title.border_line_color = 'green'
    p2.title.border_line_width = 3
    p2.title.text_font_size = '16pt'
    
    
    show(row([p1, p2]))
    

    enter image description here