pyecharts 画图 新版本讲解-以前的基本失效了

 

官网:http://pyecharts.org/#/

下面这个人的博客不错,包含Geo和map的区别

https://blog.csdn.net/weixin_40683253/article/details/87859970#%E4%BD%BF%E7%94%A8%20pyecharts%20%E6%A8%A1%E5%9D%97%E4%B8%AD%E7%9A%84%20Geo%20%E5%87%BD%E6%95%B0%EF%BC%9A

下面这个讲解是官方网址推荐的网站

https://www.echartsjs.com/tutorial.html#%E5%AF%8C%E6%96%87%E6%9C%AC%E6%A0%87%E7%AD%BE

 

Jupyter Notebook 中显示图 --运行下面代码直接在notebook中显示图了

代码测试

from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType


def geo_base() -> Geo:  # 函数注释
    c = (
        Geo()
        .add_schema(maptype="china")
        .add("geo", [list(z) for z in zip(Faker.provinces, Faker.values())])
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(
            visualmap_opts=opts.VisualMapOpts(),
            title_opts=opts.TitleOpts(title="Geo-基本示例"),
        )
    )
    return c

geo_base().render_notebook() # Jupyter Notebook 直接调用 render_notebook 随时随地渲染图表

画个地图

from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType


def geo_base() -> Geo:
    c = (
        Geo()
        .add_schema(maptype="china")
        .add("geo", [list(z) for z in zip(Faker.provinces, Faker.values())])
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(
            visualmap_opts=opts.VisualMapOpts(),
            title_opts=opts.TitleOpts(title="Geo-基本示例"),
        )
    )
    return c
geo_base().render_notebook()
from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType


def geo_base() -> Geo:
    c = (
        Geo()
        .add_schema(maptype="china")
        .add("geo", [['大连', 56],
                     ['佳木斯', 118],
                     ['双鸭山', 57],
                     ['江西', 121],
                     ['湖南', 139],
                     ['浙江', 91],
                     ['江苏', 104]])
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(
            visualmap_opts=opts.VisualMapOpts(),
            title_opts=opts.TitleOpts(title="Geo-基本示例"),
        )
    )
    return c
geo_base().render_notebook()

添加自己的坐标

from example.commons import Faker
from pyecharts import options as opts
from pyecharts.charts import Geo
from pyecharts.globals import ChartType, SymbolType

# 链式调用
c = (
        Geo()
        .add_schema(maptype="china")
        # 加入自定义的点,格式为
        .add_coordinate("测试点", 116.39770014211535, 39.90779994986951)
        # 为自定义的点添加属性
        .add("geo", [("测试点", 51)])
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(title_opts=opts.TitleOpts(title="加入自定义的点"))
)
# 在 html(浏览器) 中渲染图表
c.render()
# 在 Jupyter Notebook 中渲染图表
c.render_notebook()

python语法学习

下面的写法完全正确

x= []
(x
.append(1))

函数注释:

def f(text:str,max_len:'int>0'=80) ->str:
	"""这个是函数的帮助说明文档,help时会显示"""
    return True
"""
函数声明中,text:str
text 是参数 :冒号后面  str是参数的注释。
如果参数有默认值,还要给注释,如下写。
max_len:'int>0'=80

->str 是函数返回值的注释。

这些注释信息都是函数的元信息,保存在f.__annotations__字典中、

需要注意,python对注释信息和f.__annotations__的一致性,不做检查
不做检查,不做强制,不做验证!什么都不做。
"""

# 例如==========================================
def f(ham: 42, eggs: int = 'spam') -> "Nothing to see here":
    print("函数注释", f.__annotations__)
    print("参数值打印", ham, eggs)
    print(type(ham),type(eggs))

f("www")

 

  • 2
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值