python3.7-pyecharts-v1-liquid(水滴图)画图经典收藏

在python3.7下的pyecharts新版(v1)下水滴图(liquid)的实例,资料来源官网,并进行加工和分析,便于小白系列学习。

1.首先明白自己的pyecharts是哪个版本?
1.1老版本:pyecharts v0.5
1.2新版本:pyecharts v1.0
1.3代码编写很大不同,网上新版本的代码很少,我也是一天时间自己摸索才搞懂,走了很多弯路,所以才写这篇,对于无人指点的小白,有很大的帮助。对于水滴图的图标代码也很少,所以对于小白和学习pyecharts的朋友都有很大的帮助。

2.liquid-无边框
2.1代码:

#导出模块
from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType
#定义函数
c = (
        Liquid()
        .add("lq", [0.6, 0.7, 0.8], is_outline_show=False)
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-无边框"))
    )
c.render('1')#定格,括号内为文件名,注意单引号说明文件名省html后缀,双引号文件名,生成后缀,也可以加入路径,默认为代码.py所在的路径或文件夹。

2.2效果图:
在这里插入图片描述

3.Liquid-Shape-diamond
3.1 代码

from pyecharts import options as opts
from pyecharts.charts import Liquid,
from pyecharts.globals import SymbolType

c = (
        Liquid()
        .add("lq", [0.4, 0.7], is_outline_show=False, shape=SymbolType.DIAMOND)
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-Shape-diamond"))
    )

c.render('2')

3.2效果图
在这里插入图片描述
4.Liquid-Shape-arrow
4.1代码

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType

c = (
        Liquid()
        .add("lq", [0.3, 0.7], is_outline_show=False, shape=SymbolType.ARROW)
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-Shape-arrow"))
    )

c.render('3')

4.2效果图
在这里插入图片描述
5.Liquid-Shape-rect
5.1代码

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType
c = (
        Liquid()
        .add("lq", [0.3, 0.7], is_outline_show=False, shape=SymbolType.RECT)
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-Shape-rect"))
    )
c.render('4')

5.2效果图
在这里插入图片描述
6.Liquid-有框
6.1代码

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.globals import SymbolType
c = (
        Liquid()
        .add("lq", [0.6, 0.7])
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-有框"))
    )
c.render('5')

6.2效果图
在这里插入图片描述
7.Liquid-数据精度
7.1代码:

from pyecharts import options as opts
from pyecharts.charts import Liquid
from pyecharts.commons.utils import JsCode
from pyecharts.globals import SymbolType
c = (
        Liquid()
        .add(
            "lq",
            [0.3254],
            label_opts=opts.LabelOpts(
                font_size=50,
                formatter=JsCode(
                    """function (param) {
                        return (Math.floor(param.value * 10000) / 100) + '%';
                    }"""
                ),
                position="inside",
            ),
        )
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-数据精度"))
    )
c.render('6')

7.2效果图
在这里插入图片描述
8.经典,值得收藏,分享给大家,共同学习,进步。

  • 4
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值