✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐍Plotly, Coiled CEOs Discuss Partnering & ML Experts show us how Dash + Dask apps work Register for the Webinar.

Add subtitle to pie chart

Hey,

I am plotting multiple pie charts (for example https://plot.ly/python/pie-charts/ - second chart),
any idea how do I add subtitle to each pie?
I don’t mean a title for the whole page.

Thanks!

You should use annotations for this task: https://plot.ly/python/text-and-annotations/

I’ve just been resolving the same issue and one thing it’s useful to add here is that you can use relative location to define where to put the titles on each chart.

For example, I have two charts, one in x domain [0,48] and the other in [0.51,1] and I used the code below which seems to do a decent job of aligning the subtitle to the right place

layout.update(dict(annotations= [{'x': 0.24, 'y':0.95 
                                      ,'text': 'Previous 30 Days'
                                      ,'font': { 'color': 'rgb(55, 128, 191)', 'size': 14}
                                      ,'showarrow':False, 'xanchor':'center' },
                                     {'x': 0.76, 'y':0.95 
                                      ,'text': 'Last 30 Days' 
                                      ,'font': { 'color': 'rgb(55, 128, 191)', 'size': 14}
                                      ,'showarrow':False, 'xanchor':'center' } ]))