爬虫数据可视化

使用plotly,将爬虫获取的数据可视化,代码如下

import plotly.offline as py
from plotly.graph_objs import Scatter, Layout
import plotly.graph_objs as go
import pandas as pd
data = pd.read_csv('2018-05-27.csv')#载入数据
data.rename(columns = {'Unnamed: 0':'Name'},inplace=True)#rename index列

data = data[data['win_rate']>0.5]
data = data[data['select_num']>50]#获取胜率超过0.5且挑选超过50的数据
#创建柱状图
im = go.Bar(
    x = data['Name'],#x轴
    y = data['win_rate'],#y轴
    marker =dict(
        color = data['select_num'],#颜色跟随
        # size = data['select_num'],
        colorscale = 'Reds',#选择色系
        colorbar = dict(title = 'SelectTimes'),#colorbar添加title
        showscale = True#现实colorbar
    )
)
layout = go.Layout(#调整布局
    title = 'The hotest heros',
    autosize = False ,
    width = 1500,
    height = 600,
    xaxis = dict(title = 'Heros'),
    yaxis = dict(title = 'Rate of win'),
)
fig = go.Figure(data = [im],layout =layout)
py.plot(fig)

可视化结果

 

转载于:https://www.cnblogs.com/rokichen/p/9097357.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值