pyecharts新版本的运用

官方链接:https://pyecharts.org/#/zh-cn/global_options

二话不说,我的实际案例:

pyecharts新版本案例

(1)条形图

from pyecharts.charts import Bar

from pyecharts import options as opts

# 条形图

from pyecharts.globals import ThemeType



bar = (

    Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))

        .add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])

        .add_yaxis("商家A", [5, 20, 36, 10, 75, 90])

        .add_yaxis("商家B", [15, 6, 45, 20, 35, 66])

        .set_global_opts(title_opts=opts.TitleOpts (title="商家销售情况", subtitle="商家对比"))

)
)
bar.render()

实验结果:

 

(2)雷达图

from pyecharts import options as opts
from pyecharts.charts import Page, Radar
#雷达图
v1 = [[4300, 10000, 28000, 35000, 50000, 19000]]
v2 = [[
5000, 14000, 28000, 31000, 42000, 21000]]
def radar_base() -> Radar:
    c = (
        Radar()
            .add_schema(
           
schema=[
                opts.RadarIndicatorItem(
name="销售", max_=6500),
               
opts.RadarIndicatorItem(name="管理", max_=16000),
               
opts.RadarIndicatorItem(name="信息技术", max_=30000),
               
opts.RadarIndicatorItem(name="客服", max_=38000),
               
opts.RadarIndicatorItem(name="研发", max_=52000),
               
opts.RadarIndicatorItem(name="市场", max_=25000),
           
]
        )
            .add(
"预算分配", v1)
            .add(
"实际开销", v2)
            .set_series_opts(
label_opts=opts.LabelOpts(is_show=False))
            .set_global_opts(
title_opts=opts.TitleOpts(title="部门开销"))
    )
   
return c
c = radar_base()
c.render(
'leida.html')

实验结果

 

(3)词云图

from pyecharts import options as opts
from pyecharts.charts import  WordCloud
words = [
    (
"Sam S Club", 10000),
   
("Macys", 6181),
   
("Amy Schumer", 4386),
   
("Jurassic World", 4055),
   
("Charter Communications", 2467),
   
("Chick Fil A", 2244),
   
("Planet Fitness", 1868),
   
("Pitch Perfect", 1484),
   
("Express", 1112),
   
("Home", 865),
   
("Johnny Depp", 847),
   
("Lena Dunham", 582),
]
def wordcloud_base() -> WordCloud:
    c = (
        WordCloud()
        .add(
"", words, word_size_range=[20, 100])
        .set_global_opts(
title_opts=opts.TitleOpts(title="词云"))
    )
   
return c
c=wordcloud_base()
c.render(
'ciyun.html')

实验结果

 

uploading.4e448015.gif正在上传…重新上传取消

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值