Visualization of multidimensional data Pyecharts

1. FIG cube histogram polylines

Representing a one-dimensional coordinate axis y

from pyecharts.charts import Bar
from pyecharts import options as opts
bar = Bar()
y1 = [28, 32, 15, 45]
x2 = ['美女', '模特', '公主', '学生']
y2 = [20, 30, 10, 40]
bar.add_xaxis(x2)
bar.add_yaxis('KTV', y1)
bar.add_yaxis('98', y2)
bar.set_global_opts(title_opts=opts.TitleOpts(title='夜总会情况'))
bar.render()

Here Insert Picture Description
Similarly a line chart, change the Bar Line
Here Insert Picture Description

2. The display multiple sets of line graphs and histograms

from pyecharts.charts import Bar, Grid
from pyecharts import options as opts
from pyecharts.globals import ThemeType

t1 = Bar()
x1 = ['帅哥', '青年', '男神', '男人']
y1 = [28, 32, 15, 45]
t1.add_xaxis(x1)
t1.add_yaxis('KTV', y1)
t1.set_global_opts(title_opts=opts.TitleOpts(title='夜总会情况'), legend_opts=opts.LegendOpts(pos_left="100"))
             
              设置角标位置                   

t2 = Bar()
x2 = ['美女', '模特', '公主', '学生']
y2 = [20, 30, 10, 40]
t2.add_xaxis(x2)
t2.add_yaxis('98', y2)
t2.set_global_opts(title_opts=opts.TitleOpts(title='夜总会情况'), legend_opts=opts.LegendOpts(pos_right="20"))

引入网格
g1 = Grid(init_opts=opts.InitOpts(theme=ThemeType.DARK))
g1.add(t1, grid_opts=opts.GridOpts(pos_left="55%"))
              添加并设置位置
g1.add(t2, grid_opts=opts.GridOpts(pos_right="55%"))
g1.render()


Here Insert Picture Description
Similarly line chart, simply change Line Bar
Here Insert Picture Description

3. Set the table to select pictures

from pyecharts.charts import Bar, Tab
from pyecharts import options as opts
from pyecharts.globals import ThemeType

t1 = Bar(init_opts=opts.InitOpts(theme=ThemeType.MACARONS))
x1 = ['帅哥', '青年', '男生', '男生']
y1 = [28, 32, 15, 45]
t1.add_xaxis(x1)
t1.add_yaxis('KTV', y1)
t1.set_global_opts(title_opts=opts.TitleOpts(title='清吧'))

t2 = Bar(init_opts=opts.InitOpts(theme=ThemeType.DARK))
x2 = ['美女', '模特', '公主', '学生']
y2 = [20, 30, 10, 40]
t2.add_yaxis('98', y2)
t2.set_global_opts(title_opts=opts.TitleOpts(title='夜店'))

g1 = Tab()
g1.add(t1, '清吧')
g1.add(t2, '夜总会')
     加入表格根据标题对号入座
g1.render()

Here Insert Picture Description

4. Make a scatter plot

The Bar can be changed Scatter

Here Insert Picture Description

5.3D histogram

from pyecharts.charts import Bar3D
from pyecharts import options as opts
from pyecharts.globals import ThemeType

x = list(range(10))
y = list(range(10))
z = list(range(10))
data = [[x[i], y[i], z[i]] for i in range(len(z))]

生成每组三个数据的二维数组
[[0, 0, 0], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5],
[6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]

t = Bar3D(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
t.add('', data, xaxis3d_opts=opts.Axis3DOpts(x, type_='category'),
      yaxis3d_opts=opts.Axis3DOpts(y, type_='category'),
      zaxis3d_opts=opts.Axis3DOpts(z, type_='value'))

设置x,y轴为横轴,z轴为竖轴

t.set_global_opts(visualmap_opts=opts.VisualMapOpts(max_=10), title_opts=opts.TitleOpts(title='3D图'))

设置图片的最值

t.render()

Here Insert Picture Description
FIG. 3D view may be rotated 360 °

Here Insert Picture Description

6. The scalable moving pattern generation

from pyecharts.charts import Line, Page
from pyecharts import options as opts
from pyecharts.globals import ThemeType

t1 = Line(init_opts=opts.InitOpts(theme=ThemeType.MACARONS))
x1 = ['帅哥', '青年', '男生', '男生']
y1 = [28, 37, 15, 40]
t1.add_xaxis(x1)
t1.add_yaxis('ktv', y1)
t1.set_global_opts(title_opts=opts.TitleOpts(title='清吧'))

t2 = Line(init_opts=opts.InitOpts(theme=ThemeType.DARK))
x2 = ['美女', '模特', '公主', '学生']
y2 = [20, 30, 10, 40]
t2.add_xaxis(x2)
t2.add_yaxis('98', y2)
t2.set_global_opts(title_opts=opts.TitleOpts(title='夜店'))

page = Page(layout=Page.DraggablePageLayout)
page.add(t1, t2)
page.render()


做出两张图,之后引入Page模块加入

Here Insert Picture Description
It can not be changed after the graphics can be saved but save

Additional part

1. Map visualization

Here from Shaanxi map

from pyecharts.charts import Map
from pyecharts import options as opts
from pyecharts.globals import ThemeType, ChartType, SymbolType

g0 = Map(init_opts=opts.InitOpts(theme=ThemeType.DARK))
data = [['榆林市', 20], ['延安市', 100], ['安康市', 80], ['西安市', 30], ['宝鸡市', 50]]
g0.add('数量', data, '陕西', is_map_symbol_show=True)

设置是否显示 点

g0.set_series_opts(label_opts=opts.LabelOpts(is_show=False))

设置是否自动显示其中城市名称,注意,市级单位要加 "市"

g0.set_global_opts(title_opts=opts.TitleOpts(title='陕西地图'),
                   visualmap_opts=opts.VisualMapOpts(is_piecewise=True))

设置左下角是否显示图标,此处设置显示

g0.render()


使用 Map函数 

Here Insert Picture Description

When the setting is not displayed icon, the value of the scroll bar below

Here Insert Picture Description
Scroll bars may be pulled to display graphics according to the scroll bar range
or the default is not within the scope of black

Here Insert Picture Description

Published 108 original articles · won praise 12 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_42719822/article/details/104515230