Python笔记:雷达图

我们两清 提交于 2020-08-05 14:44:51
import pandas as pd

from pyecharts import options as opts
from pyecharts.charts import Radar

df1=ts.get_hist_data('600132',start='2018-01-03',end='2018-01-03')#获取2018-01-03的600132股票数据
name=list(df1)#获取列名
v1=[list(df1.ix[0])]
df2=ts.get_hist_data('600132',start='2018-01-02',end='2018-01-02')#获取2018-01-02的600132股票数据
v2=[list(df2.ix[0])]
df=pd.concat([df1,df2],axis=0)
up=list(df.describe().ix['max']*1.1)#设置上限
c = (
        Radar()
        .add_schema(
            schema=[
                opts.RadarIndicatorItem(name=name[i], max_=up[i]) for i in range(len(name))   
            ]
        )
        .add("2018-01-03", v1)
        .add("2018-01-02", v2,color="#0004a1")
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(title_opts=opts.TitleOpts(title="Radar-基本示例"))
    )
c.render_notebook()

 

import pandas as pd

from pyecharts import options as opts
from pyecharts.charts import Radar

df1=ts.get_hist_data('600132',start='2018-01-03',end='2018-01-03')#获取2018-01-03的600132股票数据
name=list(df1)#获取列名
v1=[list(df1.ix[0])]
df2=ts.get_hist_data('600132',start='2018-01-02',end='2018-01-02')#获取2018-01-02的600132股票数据
v2=[list(df2.ix[0])]
df=pd.concat([df1,df2],axis=0)
up=list(df.describe().ix['max']*1.1)#设置上限
c = (
        Radar()
        .add_schema(
            schema=[
                opts.RadarIndicatorItem(name=name[i], max_=up[i]) for i in range(len(name))   
            ]
        )
        .add("2018-01-03", v1)
        .add("2018-01-02", v2,color="#0004a1")
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(title_opts=opts.TitleOpts(title="Radar-基本示例"),
        legend_opts=opts.LegendOpts(selected_mode="single"))
    )
c.render_notebook()

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!