圆月山庄资源网 Design By www.vgjia.com

Grid并行显示多张图

注意: 第一个图需为 有 x/y 轴的图,即不能为 Pie,其他位置顺序任意

from pyecharts import Bar, Line, Scatter, EffectScatter, Grid
'''
 Grid类:并行显示多个图表 TODO 第一个图需为 有 x/y 轴的图,即不能为 Pie,其他位置顺序任意。
'''

attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
bar = Bar("柱状图示例", title_pos="65%")
bar.add("商家A", attr, v1, is_stack=True)
bar.add("商家B", attr, v2, is_stack=True, legend_pos="80%")

line = Line("折线图示例")
attr = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
line.add(
 "最高气温",
 attr,
 [11, 11, 15, 13, 12, 13, 10],
 mark_point=["max", "min"],
 mark_line=["average"],
)
line.add(
 "最低气温",
 attr,
 [1, -2, 2, 5, 3, 2, 0],
 mark_point=["max", "min"],
 mark_line=["average"],
 legend_pos="20%",
)

v1 = [5, 20, 36, 10, 75, 90]
v2 = [10, 25, 8, 60, 20, 80]
scatter = Scatter("散点图示例", title_top="50%", title_pos="65%")
scatter.add("scatter", v1, v2, legend_top="50%", legend_pos="80%")

es = EffectScatter("动态散点图示例", title_top="50%")
es.add(
 "es",
 [11, 11, 15, 13, 12, 13, 10],
 [1, -2, 2, 5, 3, 2, 0],
 effect_scale=6,
 legend_top="50%",
 legend_pos="20%",
)

# TODO 配置Grid类
grid = Grid(height=720, width=1200) # 初始化,参数可传page_title,width,height
grid.add(bar, grid_bottom="60%", grid_left="60%") # 添加要展示的图表,并设置显示位置
grid.add(line, grid_bottom="60%", grid_right="60%") # 添加要展示的图表,并设置显示位置
grid.add(scatter, grid_top="60%", grid_left="60%") # 添加要展示的图表,并设置显示位置
grid.add(es, grid_top="60%", grid_right="60%") # 添加要展示的图表,并设置显示位置

grid.render("./pyecharts_html/Grid_并行显示多张图表.html")

overlap图表混合使用

from pyecharts import Line, Bar, Overlap
'''
 多个x y轴示例
'''

attr = ["{}月".format(i) for i in range(1, 13)]
v1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
v2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
v3 = [2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2]

bar = Bar()
bar.add("蒸发量", attr, v1)
bar.add("降水量", attr, v2, yaxis_formatter=" ml",
 yaxis_interval=50, yaxis_max=250)

line = Line()
line.add("平均温度", attr, v3, yaxis_formatter=" °C", yaxis_interval=5)

overlap = Overlap(width=1200, height=600) # 实例化
# 默认不新增 x y 轴,并且 x y 轴的索引都为 0
overlap.add(bar)
# 新增一个 y 轴,此时 y 轴的数量为 2,第二个 y 轴的索引为 1(索引从 0 开始),所以设置 yaxis_index = 1
# 由于使用的是同一个 x 轴,所以 x 轴部分不用做出改变
overlap.add(line, yaxis_index=1, is_add_yaxis=True)

overlap.render("./pyecharts_html/Overlap_图表混合.html")

Page一个页面顺序渲染多个图表

from pyecharts import *

page = Page() # 实例化page类

# line
attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
line = Line("折线图示例")
line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10],
  mark_point=["max", "min"], mark_line=["average"])
line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0],
  mark_point=["max", "min"], mark_line=["average"])

page.add(line) # TODO 向page中添加图表

# pie
attr = ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
v1 = [11, 12, 13, 10, 10, 10]
pie = Pie("饼图-圆环图示例", title_pos='center')
pie.add("", attr, v1, radius=[40, 75], label_text_color=None,
 is_label_show=True, legend_orient='vertical', legend_pos='left')

page.add(pie) # TODO 向page中添加图表

# kline
v1 = [[2320.26, 2320.26, 2287.3, 2362.94],
 [2300, 2291.3, 2288.26, 2308.38],
 [2295.35, 2346.5, 2295.35, 2345.92],
 [2347.22, 2358.98, 2337.35, 2363.8],
 [2360.75, 2382.48, 2347.89, 2383.76],
 [2383.43, 2385.42, 2371.23, 2391.82],
 [2377.41, 2419.02, 2369.57, 2421.15],
 [2425.92, 2428.15, 2417.58, 2440.38],
 [2411, 2433.13, 2403.3, 2437.42],
 [2432.68, 2334.48, 2427.7, 2441.73],
 [2430.69, 2418.53, 2394.22, 2433.89],
 [2416.62, 2432.4, 2414.4, 2443.03],
 [2441.91, 2421.56, 2418.43, 2444.8],
 [2420.26, 2382.91, 2373.53, 2427.07],
 [2383.49, 2397.18, 2370.61, 2397.94],
 [2378.82, 2325.95, 2309.17, 2378.82],
 [2322.94, 2314.16, 2308.76, 2330.88],
 [2320.62, 2325.82, 2315.01, 2338.78],
 [2313.74, 2293.34, 2289.89, 2340.71],
 [2297.77, 2313.22, 2292.03, 2324.63],
 [2322.32, 2365.59, 2308.92, 2366.16],
 [2364.54, 2359.51, 2330.86, 2369.65],
 [2332.08, 2273.4, 2259.25, 2333.54],
 [2274.81, 2326.31, 2270.1, 2328.14],
 [2333.61, 2347.18, 2321.6, 2351.44],
 [2340.44, 2324.29, 2304.27, 2352.02],
 [2326.42, 2318.61, 2314.59, 2333.67],
 [2314.68, 2310.59, 2296.58, 2320.96],
 [2309.16, 2286.6, 2264.83, 2333.29],
 [2282.17, 2263.97, 2253.25, 2286.33],
 [2255.77, 2270.28, 2253.31, 2276.22]]
kline = Kline("K 线图示例")
kline.add("日K", ["2017/7/{}".format(i + 1) for i in range(31)], v1)

page.add(kline) # TODO 向page中添加图表

# radar
schema = [
 ("销售", 6500), ("管理", 16000), ("信息技术", 30000),
 ("客服", 38000), ("研发", 52000), ("市场", 25000)
]
v1 = [[4300, 10000, 28000, 35000, 50000, 19000]]
v2 = [[5000, 14000, 28000, 31000, 42000, 21000]]
radar = Radar("雷达图示例")
radar.config(schema)
radar.add("预算分配", v1, is_splitline=True, is_axisline_show=True)
radar.add("实际开销", v2, label_color=["#4e79a7"], is_area_show=False,
  legend_selectedmode='single')

page.add(radar) # TODO 向page中添加图表
page.render("./pyecharts_html/Page_一个页面渲染多张图表.html")

Timeline:时间线轮播多图

from pyecharts import Bar, Line, Timeline, Overlap
from random import randint

attr = ["{}月".format(i) for i in range(1, 7)]
bar = Bar("1 月份数据", "数据纯属虚构")
bar.add("bar", attr, [randint(10, 50) for _ in range(6)])
line = Line()
line.add("line", attr, [randint(50, 80) for _ in range(6)])
overlap = Overlap()
overlap.add(bar)
overlap.add(line)

bar_1 = Bar("2 月份数据", "数据纯属虚构")
bar_1.add("bar", attr, [randint(10, 50) for _ in range(6)])
line_1 = Line()
line_1.add("line", attr, [randint(50, 80) for _ in range(6)])
overlap_1 = Overlap()
overlap_1.add(bar_1)
overlap_1.add(line_1)

bar_2 = Bar("3 月份数据", "数据纯属虚构")
bar_2.add("bar", attr, [randint(10, 50) for _ in range(6)])
line_2 = Line()
line_2.add("line", attr, [randint(50, 80) for _ in range(6)])
overlap_2 = Overlap()
overlap_2.add(bar_2)
overlap_2.add(line_2)

bar_3 = Bar("4 月份数据", "数据纯属虚构")
bar_3.add("bar", attr, [randint(10, 50) for _ in range(6)])
line_3 = Line()
line_3.add("line", attr, [randint(50, 80) for _ in range(6)])
overlap_3 = Overlap()
overlap_3.add(bar_3)
overlap_3.add(line_3)

bar_4 = Bar("5 月份数据", "数据纯属虚构")
bar_4.add("bar", attr, [randint(10, 50) for _ in range(6)])
line_4 = Line()
line_4.add("line", attr, [randint(50, 80) for _ in range(6)])
overlap_4 = Overlap()
overlap_4.add(bar_4)
overlap_4.add(line_4)

timeline = Timeline(
   page_title = "页标签名",
   width=600,
   height=600,
   is_auto_play= True, # 是否自动播放,默认=False
   is_loop_play= True, # 是否循环播放
   is_rewind_play=False, # 反向播放
   is_timeline_show=True, # 是否显示时间线,默认=true
   timeline_play_interval=1000, # 播放间隔,ms
   timeline_symbol= "arrow", # 时间点标记图形, 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'
   timeline_symbol_size= [15,8], # 图形大小,可以是数字和列表,列表表示宽高
   timeline_left= "1% ", # 距离左边距离 , timeline_right
   timeline_bottom=0, # timeline_top
  )
timeline.add(overlap, '1 月')
timeline.add(overlap_1, '2 月')
timeline.add(overlap_2, '3 月')
timeline.add(overlap_3, '4 月')
timeline.add(overlap_4, '5 月')
timeline.render("./pyecharts_html/Timeline_时间线轮播多张图表.html")

以上这篇python pyecharts 实现一个文件绘制多张图就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

标签:
python,pyecharts,绘制图

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。