pyecharts绘制条形图、饼图、散点图、词云图、地图等常用图形(二)

简介: pyecharts绘制条形图、饼图、散点图、词云图、地图等常用图形

Kline图

from pyecharts import options as opts
from pyecharts.charts import Kline
data = [
    [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()
kline.add_xaxis([f'2030/10/{i+1}' for i in range(len(data))])
kline.add_yaxis('',data,
itemstyle_opts=opts.ItemStyleOpts(color='red',color0='green')
)
kline.set_global_opts(title_opts=opts.TitleOpts(title='Kline的基本图'))
kline.render_notebook()

image.png

funne图


from pyecharts.charts import Funnel
from pyecharts.faker import Faker
from pyecharts import options as opts
funnel = Funnel()
funnel.add('',[list(z) for z in zip(Faker.choose(),Faker.values())])
funnel.set_global_opts(title_opts=opts.TitleOpts(title='漏斗图'))
funnel.render_notebook()

image.png

WordCloud图

from pyecharts.charts import WordCloud
from pyecharts import options as opts
wc = WordCloud()
data = [
    ['ThinkPad','15.7'],
    ['联想','14.5'],
    ['惠普','14.4'],
    ['华为','11.7'],
    ['华硕','8.2'],
    ['戴尔','8.1'],
    ['Acer宏碁','4.5'],
    ['苹果','3.5'],
    ['神舟','3.2'],
    ['ROG','3.1'],
    ['机械革命','2.4'],
    ['msi微星','1.8'],
    ['外星人','1.5'],
    ['微软','1.4'],
    ['荣耀','1.2'],
    ['雷神','1'],
    ['三星','0.7'],
    ['红米','0.6'],
    ['机械师','0.5'],
    ['小米','0.5'],
    ['炫龙','0.4'],
    ['雷蛇','0.2'],
    ['壹号本','0.1'],
    ['a豆','0.1'],
    ['未来人类','0.1'],
    ['技嘉','0.1'],
    ['中柏','0.1'],
    ['VAIO','0.1'],
    ['火影','0.1'],
    ['LG','0.1'],
    ['松下','0'],
    ['麦本本','0'],
    ['吾空','0'],
    ['长城','0'],
    ['GPD','0'],
    ['清华同方','0'],
    ['神基','0'],
    ['爱尔轩','0'],
    ['酷比魔方','0'],
    ['海尔','0'],
    ['谷歌','0'],
    ['台电','0'],
    ['iru','0'],
    ['攀升IPASON','0'],
    ['NEC','0'],
    ['夏普','0'],
    ['京东京造','0'],
    ['锡恩帝','0'],
    ['皓勤','0'],
    ['Intel','0'],
]
wc.add('',data)
wc.set_global_opts(title_opts=opts.TitleOpts('词云图'))
wc.render_notebook()

image.png

Radar图

from pyecharts.charts import Radar
from pyecharts import options as opts
radar = Radar()
data1 = [[8,7,8,8,9,7]]
data2 = [[9,5,7,8,6,7]]
radar.add_schema(
    schema=[
        opts.RadarIndicatorItem(name='拍照',max_=10),
        opts.RadarIndicatorItem(name='外观',max_=10),
        opts.RadarIndicatorItem(name='性能',max_=10),
        opts.RadarIndicatorItem(name='屏幕',max_=10),
        opts.RadarIndicatorItem(name='内存',max_=10),
        opts.RadarIndicatorItem(name='系统',max_=10)]
)
radar.add('OPPO',data1)
radar.add('华为',data2)
radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
radar.set_global_opts(title_opts=opts.TitleOpts('雷达图'))
radar.render_notebook()

image.png

Map图

from pyecharts.charts import Map
from pyecharts import options as opts
map = Map()
map.add('',[['河北',10],['四川',20]],is_map_symbol_show=False)
map.set_global_opts(
    title_opts=opts.TitleOpts('地图'),
    visualmap_opts=opts.VisualMapOpts()
)
map.render_notebook()

image.png

from pyecharts.charts import Map
from pyecharts import options as opts
map = Map()
map.add('',
[['西安市',10],['安康市',20]],
maptype='陕西',
is_map_symbol_show=False,
label_opts=opts.LabelOpts(is_show=True))
map.set_global_opts(
    title_opts=opts.TitleOpts('陕西省'),
    visualmap_opts=opts.VisualMapOpts()
)
map.render_notebook()

image.png

组合图

from pyecharts.charts import Bar,Line
from pyecharts import options as opts
x = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
bar =Bar()
bar.add_xaxis(x)
bar.add_yaxis('蒸发量',
[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3],
label_opts=opts.LabelOpts(is_show=False))
bar.add_yaxis('降水量',
[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],
label_opts=opts.LabelOpts(is_show=False))
bar.set_global_opts(
    title_opts=opts.TitleOpts('混合图'),
    tooltip_opts=opts.TooltipOpts(is_show=True,trigger='axis',axis_pointer_type='cross'),
    xaxis_opts= opts.AxisOpts(type_='category',axispointer_opts=opts.AxisPointerOpts(is_show=True,type_='shadow'))
    )
bar.extend_axis(yaxis=opts.AxisOpts(
    name='温度',min_=0,max_= 25,
    interval = 5,
    axislabel_opts = opts.LabelOpts(formatter='{value} °C')
))
line = Line()
line.add_xaxis(x)
line.add_yaxis('平均温度',
[2.0, 2.2, 3.3, 4.5, 6.3, 10.2, 20.3, 23.4, 23.0, 16.5, 12.0, 6.2],
yaxis_index=1,
label_opts=opts.LabelOpts(is_show=False)
)
bar.overlap(line) # 合并图
bar.render_notebook()

image.png

Timeline图

from pyecharts.charts import Bar,Timeline
from pyecharts import options as opts
from pyecharts.faker import Faker
x = Faker.choose()
tl = Timeline() 
for i in range(2000,2006):
    bar = Bar()
    bar.add_xaxis(x)
    bar.add_yaxis('A',Faker.values())
    bar.add_yaxis('B',Faker.values())
    bar.set_global_opts(title_opts=opts.TitleOpts(f'{i}年的数据表'))
    tl.add(bar,f'{i}年')
tl.render_notebook()

image.png

目录
相关文章
|
3月前
【SPSS】基础图形的绘制(条形图、折线图、饼图、箱图)详细操作过程(下)
【SPSS】基础图形的绘制(条形图、折线图、饼图、箱图)详细操作过程
113 0
|
3月前
【SPSS】基础图形的绘制(条形图、折线图、饼图、箱图)详细操作过程(上)
【SPSS】基础图形的绘制(条形图、折线图、饼图、箱图)详细操作过程
72 0
|
5月前
|
存储 数据可视化
使用 plotly 绘制旭日图
使用 plotly 绘制旭日图
74 0
|
8月前
|
编解码 前端开发 JavaScript
Matplotlib使用和绘制二维图表
Matplotlib使用和绘制二维图表
63 0
|
机器学习/深度学习 API Python
seaborn画直方图、条形图、盒图、散点图等常用图形
seaborn画直方图、条形图、盒图、散点图等常用图形
206 0
seaborn画直方图、条形图、盒图、散点图等常用图形
|
12月前
|
数据可视化 数据处理
R绘图案例|基于分面的折线图绘制
R绘图案例|基于分面的折线图绘制
178 0
|
开发者
pyecharts基础之柱状图的绘制
pyecharts分为v0.5.X和v1两个大版本,0.5.x 版本将不再进行维护推荐使用v1版本
69 0
|
数据可视化 Python
可视化库Matplotlib-折线统计图
可视化库Matplotlib-折线统计图
可视化库Matplotlib-折线统计图
|
数据可视化 数据挖掘 定位技术
pyecharts绘制条形图、饼图、散点图、词云图、地图等常用图形(一)
pyecharts绘制条形图、饼图、散点图、词云图、地图等常用图形
286 0
pyecharts绘制条形图、饼图、散点图、词云图、地图等常用图形(一)
|
开发者 Python
matplotlib画折线图、直方图、饼图、散点图等常见图形
matplotlib画折线图、直方图、饼图、散点图等常见图形
207 0
matplotlib画折线图、直方图、饼图、散点图等常见图形