plotly绘制简单图形<5>--饼形图附加
程序员文章站
2022-07-14 12:54:15
...
plotly绘制简单图形<4>--饼形图里说了饼形图的基本设置,
这里补充一个怎样设置两个饼图的方法(数据是爬取京东手机和电脑价格数据分析结果)
import plotly.plotly as py
import plotly.graph_objs as go
fig = {
"data": [
{
"values": [841, 222, 4, 13, 48, 65, 244, 25, 3024, 28786],
"labels": [0,1,2,3,4,5,6,7,8,9],
"domain": {"x": [0, .48]},
"name": "GHG Emissions",
"hoverinfo":"label+percent+name",
"hole": .4,
"type": "pie"
},
{
"values": [154, 60, 30, 33, 20, 269, 152, 52, 2919, 5990],
"labels": [0,1,2,3,4,5,6,7,8,9],
"text":["CO2"],
"textposition":"inside",
"domain": {"x": [.52, 1]},
"name": "CO2 Emissions",
"hoverinfo":"label+percent+name",
"hole": .4,
"type": "pie"
}],
"layout": {
"title":"手机电脑价格尾数分布",
"annotations": [
{
"font": {
"size": 20
},
"showarrow": False,
"text": "电脑",
"x": 0.20,
"y": 0.5
},
{
"font": {
"size": 20
},
"showarrow": False,
"text": "手机",
"x": 0.8,
"y": 0.5
}
]
}
}
py.iplot(fig, filename='donut')