pyecharts气泡图

import pandas as pd
from pyecharts.charts import Scatter
from pyecharts import options as opts

data = pd.read_csv('../crimeRatesByState2005.csv')
data2 = data[data.state!='United States']
data2 = data2[data2.state!='District of Columbia']
data2 = data2[['murder','burglary']]
data2 = data2.values.tolist()
# data2.sort(key=lambda x: x[0])
x_data = [d[0] for d in data2]

y_data = [d[1] for d in data2]

s=(
    Scatter(init_opts=opts.InitOpts(width="1000px", height="580px"))
    .add_xaxis(xaxis_data=x_data)
    .add_yaxis(
        series_name="气泡图散点图",
        y_axis=y_data,
        symbol_size=40,
        label_opts=opts.LabelOpts(is_show=False),
    )
    .set_series_opts()
    .set_global_opts(
        title_opts=opts.TitleOpts(title="2005年美国各州的犯罪情况"),
        visualmap_opts=opts.VisualMapOpts(is_show=True,type_="size", max_=1400, min_=0),
        xaxis_opts=opts.AxisOpts(
            type_="value", splitline_opts=opts.SplitLineOpts(is_show=True)
        ),
        yaxis_opts=opts.AxisOpts(
            type_="value",
            axistick_opts=opts.AxisTickOpts(is_show=True),
            splitline_opts=opts.SplitLineOpts(is_show=True),
        ),
        tooltip_opts=opts.TooltipOpts(is_show=True),
    )
    
)

你可能感兴趣的:(python,java,开发语言)