Moving a subplot away from subplot title

I am a new plotly user and I’ve created a figure with several subplots. How can I move a pie chart down so that the data does not overlap the subplot title?

plotlyPie

Hi @avtpg welcome to the forum! A subplot title is a layout annotation object, as you can see by doing a print(fig) to inspect the structure of your figure. You can modify the annotation using fig.update_annotations as in the code below

from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(1, 2, specs=[[{'type':'domain'}, {'type':'domain'}]], 
                    subplot_titles=["My big title here", "Another title"])
fig.add_trace(go.Pie(values=[1, 90], pull=[0.5, 0]), 1, 1)
fig.add_trace(go.Pie(values=[1, 90], pull=[0.2, 0]), 1, 2)
fig.update_annotations(y=1.2, selector={'text':'My big title here'})
fig.update_annotations(y=1.1, selector={'text':'Another title'})
fig.show()

1 Like

The solution above moved the title up; if you prefer to move subplot down, you can do it with

from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(1, 2, specs=[[{'type':'domain'}, {'type':'domain'}]], 
                    subplot_titles=["My big title here", "Another title"])
fig.add_trace(go.Pie(values=[1, 90], pull=[0.5, 0], name='first plot'))
fig.add_trace(go.Pie(values=[1, 90], pull=[0.2, 0]), 1, 2)
fig.update_traces(domain=dict(x=[0, 0.45], y=[0, 0.8]), 
                  selector={'name':'first plot'})
fig.show()
2 Likes

Thank you so much, apologies for the late response - I forgot to follow up on my question. Definitely appreciate the help!