pyecharts操作三

pyecharts操作三

  • pyecharts 是一个用于生成Echarts图表的Python库。Echarts是百度开源的一个数据可视化JS库,可以生成一些非常酷炫的图表。

  • 环境安装

    • pip install pyecharts
  • 检查版本

import pyecharts
print(pyecharts.version)
2.0.3

  • GL关系图

import random

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

nodes = []
for i in range(50):
for j in range(50):
nodes.append(
opts.GraphGLNode(
x=random.random() * 958,
y=random.random() * 777,
value=1,
)
)

links = []
for i in range(50):
for j in range(50):
if i < 50 - 1:
links.append(
opts.GraphGLLink(
source=i + j * 50,
target=i + 1 + j * 50,
value=1,
)
)
if j < 50 - 1:
links.append(
opts.GraphGLLink(
source=i + j * 50,
target=i + (j + 1) * 50,
value=1,
)
)

gl = (
GraphGL(init_opts=opts.InitOpts())
.add(
series_name=“”,
nodes=nodes,
links=links,
itemstyle_opts=opts.ItemStyleOpts(color=“rgba(255,231,114,0.8)”),
linestyle_opts=opts.LineStyleOpts(color=“rgba(255,231,114,0.8)”, width=3),
force_atlas2_opts=opts.GraphGLForceAtlas2Opts(
steps=5,
edge_weight_influence=4,
),
)
.set_dark_mode()
)
gl.render_notebook()
在这里插入图片描述

  • 图形组件

from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.commons.utils import JsCode
from pyecharts.faker import Faker

gr = (
Bar()
.add_xaxis(Faker.choose())
.add_yaxis(“商家A”, Faker.values())
.add_yaxis(“商家B”, Faker.values())
.set_global_opts(
title_opts=opts.TitleOpts(title=“图形组件示例”),
graphic_opts=[
opts.GraphicGroup(
graphic_item=opts.GraphicItem(
rotation=JsCode(“Math.PI / 4”),
bounding=“raw”,
right=110,
bottom=110,
z=100,
),
children=[
opts.GraphicRect(
graphic_item=opts.GraphicItem(
left=“center”, top=“center”, z=100
),
graphic_shape_opts=opts.GraphicShapeOpts(width=400, height=50),
graphic_basicstyle_opts=opts.GraphicBasicStyleOpts(
fill=“rgba(0,0,0,0.3)”
),
),
opts.GraphicText(
graphic_item=opts.GraphicItem(
left=“center”, top=“center”, z=100
),
graphic_textstyle_opts=opts.GraphicTextStyleOpts(

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ak2111

你的鼓励将是我创作的最大动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值