Search code examples
pythonholoviewsholoviz

Set title to a simple Holoviews plot (python)


I have a simple Holoviews plot, in this case a scatter or points plot, but it has no title.
How do I add a title to this plot?

# import libraries
import numpy as np
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')

# create sample data    
data = np.random.normal(size=[50, 2])

# create simple plot (but it has no title)
hv.Points(data)

Solution

  • You can add a title to your simple Holoviews plot by using argument label='New title' when creating your graph:

    # import libraries
    import numpy as np
    import holoviews as hv
    from holoviews import opts
    hv.extension('bokeh')
    
    # create sample data    
    data = np.random.normal(size=[50, 2])
    
    # create simple plot and add title with label='New title just added'
    hv.Points(data, label='New title just added')
    

    If you would like to add a title to an Overlay plot, check this question + answer:
    Using Holoviews, how can I set a title?

    Resulting plot with new title:

    New title added to simple holoviews plot