废话不说直接上代码:
%matplotlib inline
import numpy as np
import io,pandas as pd
import matplotlib.pyplot as plt
myString='''
类别 订单量占比 门店数占比 交易额占比
小龙虾 0.6 0.9 1.7
川湘菜 4.5 4.8 6.5
烤串 2.9 4.5 4.8
面馆 3.8 8.0 3.1
包子/粥 6.3 3.5 4.7
西式快餐 7.9 7.5 9.2
快餐简餐 22.1 16.3 18.8
'''
df = pd.read_csv(io.StringIO(myString), sep=' ')
df[['订单量占比','门店数占比','交易额占比']] = df[['订单量占比','门店数占比','交易额占比']].applymap(lambda x:pd.to_numeric(x))
import plotly.graph_objects as go
planets = list(df['类别'])
planet_colors = ['rgb(135, 135, 125)', 'rgb(210, 50, 0)', 'rgb(50, 90, 255)','rgb(178, 0, 0)', 'rgb(235, 235, 210)', 'rgb(235, 205, 130)','rgb(55, 255, 217)']
x = list(df['订单量占比'])
y = list(df['门店数占比'])
z = list(df['交易额占比'])
planet_diameter = list(df['订单量占比']*10000)
#