How to add a secondary Title to Plotly graph

I have a number of plotly graphs and I want to add several components from the DataFrame to the plot title area. I have the bulk of the text in the title, but what I would like to do is add more text where I have indicated in yellow in the picture below.
One way is to have a very long title with a lot of spaces in it, but is there a way to have two titles (or a title and something else that looks like a title) and be able to control the position of them? Something like two titles, one justified left, one justified right? I’ve looked at β€˜labels’ but they are inside the graph and I’m using the Subplot titles as shown.

figN.update_layout(template="plotly_dark",
title_text="Node Separations.   Line: "+str(name)+" Seq: "+str(Seq))

@adamschroeder
Hi Adam. I have the same question as OP here. Do you happen to know if this is possible?

Hi,

You could use standard CSS to position whatever, wherever on your graph in case it’s not possible with the existing tools.

As per the example, I have put in info button on the left upper side of my graph. which has popup functionality when you hover over it.

Hope it helps,
J.

1 Like

@jcuypers, @plottingly
You can add a secondary title (text) as an annotation with xref="paper", yref="paper": https://plotly.com/python/text-and-annotations/

2 Likes

Thank you @jcuypers and @empet for answering @plottingly .

Hi @plottingly
To build on @empet 's answer, here’s an example:

import plotly.express as px

df = px.data.gapminder().query("year==2007 and continent=='Americas'")

fig = px.scatter(df, x="gdpPercap", y="lifeExp", text="country", log_x=True, size_max=60)

fig.add_annotation(text=f"Graph Title for {df.columns[3]} and {df.columns[5]}",
                  xref="paper", yref="paper",
                  x=0.5, y=1.05, showarrow=False)

fig.show()
1 Like

Thanks for the inputs!
That’s quite simple and very customizable. I’m already using it.