python - pyecharts visual realization of "three" - Advanced Dynamic graphics [common statistical charts - visual feast]

1, pyecharts mounting Introduction

       Baidu is to call the ECharts and python interface. ECharts English word for Enterprise Charts, graphs do business-grade data, is Baidu's open source data visualization tools. We use the python pyecharts library, just a few lines of code to draw a shining picture. It is not hard to learn. Of course, if you do not, then install pyecharts look at my suggestion pyecharts installation guide, full of success! [PS: If you are sure there will be a variety of problems from other sources installed, do not worry my tutorial]
pyecharts Installation Tutorial: Installation unsuccessful me give you a head when the ball
pyecharts official website describes the various parameters
pyecharts official website
if that example click here to see the color does not look good on a color code table, choose your favorite color replacement

2, pyecharts drawing realize anaconda (the picture is dynamic, showing still pictures here)

       If you do not like the color example, you can click here and then into your favorite color!

2.1 Creating dynamic - pie chart, FIG ring combination

from pyecharts import Pie #饼图环形套图
pie =Pie("饼图环形组合图", title_pos='center', width=800, height=400,title_top='5%',background_color='#00ffff')
pie.add("电影类型", ['戏剧','喜剧','动作','惊悚','爱情','恐怖片'],[335, 321, 234, 135, 251, 148],
        radius=[40, 55],is_label_show=True,is_random=True)
#外层环形图 radius 环状的大小
pie.add("上映地点比例", ['贵州', '深圳', '北京'], [335, 679, 204], radius=[0, 30], legend_orient='vertical',
        legend_pos='left',is_random=True) #内层饼图
pie.show_config()
pie.render()

Here Insert Picture Description

Making dynamic 2.2 - Rose, FIG ring combination

import random  #玫瑰环形组合图
from pyecharts import Pie 
attr =['戏剧','喜剧','动作','惊悚','爱情','恐怖片']
pie =Pie("玫瑰环形组合图",title_pos='center', width=800, height=400,title_top='5%',background_color='#00ffff')
pie.add("", attr, [random.randint(0, 100) for _ in range(6)], radius=[50, 55], center=[30, 50],is_random=True)
 # 第一个图的环  # range(6) 有六个玫瑰花瓣和六个扇叶构成环形 is_random设置随机颜色 center该图的位置中心点
pie.add("", attr, [random.randint(20, 100) for _ in range(6)], radius=[0, 45], center=[30, 50],rosetype='area')
# 第一个图的内部扇形   rosetype内部玫瑰的类型
pie.add("", attr, [random.randint(0, 100) for _ in range(6)], radius=[50, 55], center=[70, 50],is_random=True)
 # 第二个图的环
pie.add("", attr, [random.randint(20, 100) for _ in range(6)], radius=[0, 45], center=[70, 50],rosetype='radius')
# 第二个图的内部扇形
pie.show_config()   
pie.render()

Here Insert Picture Description

2.3 Dynamic Production - bar and mean adding a line

from pyecharts import Bar #月份观影量  超级吊柱状图
attr =["{}月".format(i) for i in range(1, 13)]
v2 =[759,711,679,528,502,388,302,281,267, 241,236,195]
v1 =[482,184,562,1422,34,472,1518,144,224,390,1004,258]
bar =Bar("柱状图示例",title_pos='center',title_top='5%',background_color='#00ffff')
bar.add("观影量", attr, v1, mark_line=["average"], mark_point=["max", "min"],is_random=True)
bar.add("上座量", attr, v2, mark_line=["average"], mark_point=["max", "min"],is_random=True)
bar.show_config()
bar.render()

Here Insert Picture Description

2.4 Create dynamic - a plurality of annular frame with FIG.

from pyecharts import Pie 
pie =Pie('各类电影中"好片"所占比', "构造数据", title_pos='center',title_top='5%',background_color='#00ffff')
pie.add("", ["戏剧", ""], [25, 75], center=[10, 30], radius=[18, 24], label_pos='center', 
        is_label_show=True, label_text_color=None,is_random=True )
pie.add("", ["喜剧", ""], [24, 76], center=[30, 30], radius=[18, 24], label_pos='center', 
        is_label_show=True, label_text_color=None, legend_pos='left',is_random=True)
pie.add("", ["爱情", ""], [14, 86], center=[50, 30], radius=[18, 24], label_pos='center', 
        is_label_show=True, label_text_color=None,is_random=True)
pie.add("", ["动作", ""], [11, 89], center=[70, 30], radius=[18, 24], label_pos='center', 
        is_label_show=True, label_text_color=None,is_random=True)
pie.add("", ["惊悚", ""], [27, 73], center=[90, 30], radius=[18, 24], label_pos='center',
        is_label_show=True, label_text_color=None,is_random=True)
pie.add("", ["动作", ""], [15, 85], center=[10, 70], radius=[18, 24], label_pos='center', 
        is_label_show=True, label_text_color=None,is_random=True)
pie.add("", ["科幻", ""], [54, 46], center=[30, 70], radius=[18, 24], label_pos='center', 
        is_label_show=True, label_text_color=None,is_random=True)
pie.add("", ["犯罪", ""], [26, 74], center=[50, 70], radius=[18, 24], label_pos='center',
        is_label_show=True, label_text_color=None,is_random=True)
pie.add("", ["悬疑", ""], [25, 75], center=[70, 70], radius=[18, 24], label_pos='center', 
        is_label_show=True, label_text_color=None,is_random=True)
pie.add("", ["黑色电影", ""], [28, 72], center=[90, 70], radius=[18, 24], label_pos='center',
        is_label_show=True, label_text_color=None, is_legend_show=True, legend_top="center",is_random=True)
pie.show_config()
pie.render()

Here Insert Picture Description

FIG spiral interesting embodiment -3D 2.5 (Example mesh)

from pyecharts import Line3D

import math
_data = []
for t in range(0, 25000):
    _t = t / 1000
    x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
    y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
    z = _t + 2.0 * math.sin(75 * _t)
    _data.append([x, y, z])
range_color = [
    '#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
    '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
line3d = Line3D("3D 折线图示例",'例子来源官网', width=1200, height=600,background_color='#000000')
line3d.add(
    "",
    _data,
    is_visualmap=True,
    visual_range_color=range_color,
    visual_range=[0, 30],
    grid3d_rotate_sensitivity=5,
)
line3d.render()

Here Insert Picture Description
Here Insert Picture Description

Interest Example 2.6 - petal (Example Network)

import math #花瓣
from pyecharts import Polar
data =[]
for i in range(361): 
    t =i /180*math.pi 
    r =math.sin(2*t) *math.cos(2*t)
    data.append([r, i])
polar =Polar("极坐标系示例", width=1200, height=600,background_color='#000000')
polar.add("Color-Flower", data, start_angle=0, symbol=None, axis_range=[0, None],
          area_color="#f71f24", area_opacity=0.6)
polar.show_config()
polar.render()

** ** bold style

3, end the eggs

        Focus! Focus! Next is a Python for map visualization of text columns and migration map, please do not go away, wonderful continue later! List my visual slogan: either helpful! Either interesting!

        Today, here came to an end - here is Jeruser visual feast column, let you experience a different data analysis, how work gets interesting, please continue to focus on me. Thank you for watching me Jetuser-data

Links: [https://blog.csdn.net/L1542334210]
CSND: L1542334210
Here Insert Picture Description
I wish you all success! Family fun!

Published 29 original articles · won praise 53 · views 30000 +

Guess you like

Origin blog.csdn.net/L1542334210/article/details/102681204