Multiple color in title text

Hi community,

Is it possible to have two different colors or highlight a particular word in the title text with a different color. Like below text
image

If I set a color for the title using the title_font property in update_layout it applies to the entire title string. Is it possible to have sub strings with different styles?

Thanks

Hi,

I am not sure you can have two colors in the title, but there are a few options you can consider using HTML. Otherwise, if you really want two colors, you could consider using two text annotations instead and set the position manually.

1 Like

Hi @dataturnsmeon

As @jlfsjunior suggested you can use HTML to have separate styled substrings with the <span> tag.

fig.update_layout(
    title_text="Plot Title: <span style='color:red'>Sub title in Red</span>"
)

5 Likes

Thanks a lot @jlfsjunior and @atharvakatre. This works for me :100:

1 Like