使用并排饼图实现的方法make_subplots
来自plotly 的函数如下(非常感谢@Oysiyl 提供的输入数据):
from plotly.subplots import make_subplots
import plotly.graph_objects as go
from plotly.offline import plot
fig = make_subplots(rows=1, cols=2, specs=[[{"type": "pie"}, {"type": "pie"}]])
fig.add_trace(go.Pie(
values=[16, 15, 12, 6, 5, 4, 42],
labels=["US", "China", "European Union", "Russian Federation",
"Brazil", "India", "Rest of World"
],
domain=dict(x=[0, 0.5]),
name="GHG Emissions"),
row=1, col=1)
fig.add_trace(go.Pie(
values=[27, 11, 25, 8, 1, 3, 25],
labels=["US", "China", "European Union", "Russian Federation",
"Brazil", "India", "Rest of World"
],
domain=dict(x=[0.5, 1.0]),
name="CO2 Emissions"),
row=1, col=2)
plot(fig)