Reputation: 11
I have pie charts as subplots of a figure in the sample Python code shown. When plotted, the subplot titles are nearly touching the pie. What's the easiest way to add some space between the title ("title1" and "title2") and each chart?
It would be nice if there was a settable parameter in the update_traces() method.
import plotly.graph_objs as go
from plotly.subplots import make_subplots
# Create a figure with two pie chart subplots
fig = make_subplots(rows=1, cols=2, specs=[[{"type": "pie"}, {"type": "pie"}]])
# Add pie charts to each subplot
fig.add_trace(go.Pie(title = "title1", labels=["A", "B", "C"], values=[1, 2, 3],
domain={'x': [0.1, .5], 'y': [0.65, 1.0]},), )
fig.add_trace(go.Pie(title = "title2", labels=["D", "E", "F"], values=[4, 5, 6],
domain={'x': [0.5, 1], 'y': [0.1,.65]},),)
fig.update_traces(title_font_size=24, titleposition='top center')
fig.update_layout(height=600, width=1400, title_text='Example')
# Show the figure
fig.show()
Upvotes: 1
Views: 208