最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

pyecharts繪制各種數(shù)據(jù)可視化圖表案例附效果+代碼

 更新時(shí)間:2022年06月29日 16:20:46   作者:"wink  
這篇文章主要介紹了pyecharts繪制各種數(shù)據(jù)可視化圖表案例并附效果和代碼,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,感興趣的小伙伴可以參考一下

1、pyecharts繪制餅圖(顯示百分比)

# 導(dǎo)入模塊
from pyecharts import options as opts
from pyecharts.charts import Pie
#準(zhǔn)備數(shù)據(jù)
label=['Mac口紅','Tom Ford口紅','圣羅蘭','紀(jì)梵希','花西子','迪奧','阿瑪尼','香奈兒']
values = [300,300,300,300,44,300,300,300]
# 自定義函數(shù)
def pie_base():
    c = (
        Pie()
        .add("",[list(z) for z in zip(label,values)])
        .set_global_opts(title_opts = opts.TitleOpts(title="口紅品牌分析"))
        .set_series_opts(label_opts=opts.LabelOpts(formatter=":{c} wppm3vysvbp%"))   # 值得一提的是,wppm3vysvbp%為百分比
    )
    return c
# 調(diào)用自定義函數(shù)生成render.html
pie_base().render()

2、pyecharts繪制柱狀圖

#導(dǎo)入模塊
from pyecharts.globals import ThemeType
from pyecharts import options as opts
from pyecharts.charts import Bar
#準(zhǔn)備數(shù)據(jù)
l1=['星期一','星期二','星期三','星期四','星期五','星期七','星期日']
l2=[100,200,300,400,500,400,300]
bar = (
    Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
    .add_xaxis(l1)
    .add_yaxis("柱狀圖標(biāo)簽", l2)
    .set_global_opts(title_opts=opts.TitleOpts(title="柱狀圖-基本示例", subtitle="副標(biāo)題"))
)
# 生成render.html
bar.render()

3、pyecharts繪制折線圖

#導(dǎo)入模塊
import pyecharts.options as opts
from pyecharts.charts import Line
#準(zhǔn)備數(shù)據(jù)
x=['星期一','星期二','星期三','星期四','星期五','星期七','星期日']
y1=[100,200,300,400,100,400,300]
y2=[200,300,200,100,200,300,400]
line=(
    Line()
    .add_xaxis(xaxis_data=x)
    .add_yaxis(series_name="y1線",y_axis=y1,symbol="arrow",is_symbol_show=True)
    .add_yaxis(series_name="y2線",y_axis=y2)
    .set_global_opts(title_opts=opts.TitleOpts(title="Line-雙折線圖"))
)
#生成render.html
line.render()

4、pyecharts繪制柱形折線組合圖

from pyecharts import options as opts
from pyecharts.charts import Bar, Grid, Line
#x軸的值為列表,包含每個(gè)月份
x_data = ["{}月".format(i) for i in range(1, 13)]
bar = (
    Bar()
    .add_xaxis(x_data)
#第一個(gè)y軸的值、標(biāo)簽、顏色
    .add_yaxis(
        "降雨量",
        [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 68.6, 22.0, 6.6, 4.3],
        yaxis_index=0,
        color="#5793f3",
    )

# #第二個(gè)y軸的值、標(biāo)簽、顏色
#     .add_yaxis(
#         "蒸發(fā)量",
#         [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],
#         yaxis_index=1,
#         color="#5793f3",
#     )

#右縱坐標(biāo)
    .extend_axis(
        yaxis=opts.AxisOpts(
            name="降雨量",
            type_="value",
            min_=0,
            max_=250,
            position="right",
            axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts(color="#d14a61")
            ),
            axislabel_opts=opts.LabelOpts(formatter="{value} ml"),
        )
    )
#左縱坐標(biāo)
    .extend_axis(
        yaxis=opts.AxisOpts(
            type_="value",
            name="溫度",
            min_=0,
            max_=25,
            position="left",
            axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts(color="#d14a61")
            ),
            axislabel_opts=opts.LabelOpts(formatter="{value} °C"),
            splitline_opts=opts.SplitLineOpts(
                is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)
            ),
        )
    )
    .set_global_opts(
        yaxis_opts=opts.AxisOpts(
            name="降雨量",
            min_=0,
            max_=250,
            position="right",
            offset=0,
            axisline_opts=opts.AxisLineOpts(
                linestyle_opts=opts.LineStyleOpts(color="#5793f3")
            ),
            axislabel_opts=opts.LabelOpts(formatter="{value} ml"),
        ),
        title_opts=opts.TitleOpts(title="Grid-多 Y 軸示例"),
        tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"),
    )
)
line = (
    Line()
    .add_xaxis(x_data)
    .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=2,
        color="#675bba",
        label_opts=opts.LabelOpts(is_show=False),
    )
)
bar.overlap(line)
grid = Grid()
grid.add(bar, opts.GridOpts(pos_left="5%", pos_right="20%"), is_control_axis_index=True)
grid.render()

5、pyecharts繪制散點(diǎn)圖

# 導(dǎo)入模塊
from pyecharts import  options as opts
from pyecharts.charts import Scatter
 
# 設(shè)置銷售數(shù)據(jù)
week = ["周一","周二","周三","周四","周五","周六","周日"]
c =Scatter()     # 散點(diǎn)圖繪制
c.add_xaxis(week)
c.add_yaxis("商家A",[80,65,46,37,57,68,90])
c.set_global_opts(title_opts=opts.TitleOpts(title="一周的銷售額(萬元)"))    # 設(shè)置圖表標(biāo)題
c.render()

6、pyecharts繪制玫瑰圖

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

label=['Mac口紅','Tom Ford口紅','圣羅蘭','紀(jì)梵希','花西子']
values = [100,200,250,350,400]
c = (
    Pie()
    .add(
        "",
        [list(z) for z in zip(label,values)],
        radius=["30%", "75%"],
        center=["50%", "50%"],
        rosetype="radius",
        label_opts=opts.LabelOpts(is_show=False),
    )
    .set_global_opts(title_opts=opts.TitleOpts(title="標(biāo)題"))
    .set_series_opts(label_opts=opts.LabelOpts(formatter=":{c} wppm3vysvbp%"))   # 值得一提的是,wppm3vysvbp%為百分比
    .render("玫瑰圖.html")
)

7、pyecharts繪制詞云圖

# 導(dǎo)入WordCloud及配置模塊
from pyecharts import options as opts
from pyecharts.charts import WordCloud
from pyecharts.globals import SymbolType
 
# 添加詞頻數(shù)據(jù)
words = [
    ("Sam S Club", 10000),
    ("Macys", 6181),
    ("Amy Schumer", 4386),
    ("Jurassic World", 4055),
    ("Charter Communications", 2467),
    ("Chick Fil A", 2244),
    ("Planet Fitness", 1868),
    ("Pitch Perfect", 1484),
    ("Express", 1112),
    ("Home", 865),
    ("Johnny Depp", 847),
    ("Lena Dunham", 582),
    ("Lewis Hamilton", 555),
    ("KXAN", 550),
    ("Mary Ellen Mark", 462),
    ("Farrah Abraham", 366),
    ("Rita Ora", 360),
    ("Serena Williams", 282),
    ("NCAA baseball tournament", 273),
    ("Point Break", 265),
]
 
# WordCloud模塊,鏈?zhǔn)秸{(diào)用配置,最終生成html文件
c = (
    WordCloud()
    .add("", words, word_size_range=[20, 100], shape=SymbolType.DIAMOND)
    .set_global_opts(title_opts=opts.TitleOpts(title="詞云圖"))
    .render("wordcloud_diamond.html")
)

8、pyecharts繪制雷達(dá)圖

from pyecharts import options as opts
from pyecharts.charts import Radar
v1 = [[8.5,50000,15000,8000,13000,5000]]
v2 = [[8.1,42000,13000,7000,15000,7000]]
def radar_base() ->Radar:
    c = (
        Radar()
        .add_schema(
            schema=[
                opts.RadarIndicatorItem(name='KDA',max_=10),
                opts.RadarIndicatorItem(name='輸出', max_=60000),
                opts.RadarIndicatorItem(name='經(jīng)濟(jì)', max_=20000),
                opts.RadarIndicatorItem(name='生存', max_=10000),
                opts.RadarIndicatorItem(name='推進(jìn)', max_=20000),
                opts.RadarIndicatorItem(name='刷野', max_=10000),
            ]
        )
        .add(
            '射手',v1,
            color='blue',
            #通過顏色屬性 將其填充
            areastyle_opts=opts.AreaStyleOpts(
                opacity=0.5,
                color='blue'
            ),
        )
        .add(
            '法師',v2,
            color='red',
            areastyle_opts=opts.AreaStyleOpts(
                opacity=0.5,
                color='red'
            ),
        )
        .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
        .set_global_opts(title_opts=opts.TitleOpts(title='英雄成長屬性對比'))
    )
    return c
radar_base().render("雷達(dá)圖.html")

9、pyecharts繪制散點(diǎn)圖

from pyecharts import options as opts
from pyecharts.charts import Scatter
from pyecharts.commons.utils import JsCode
from pyecharts.faker import Faker
c = (
    Scatter()
    .add_xaxis(Faker.choose())
    .add_yaxis(
        "商家A",
        [list(z) for z in zip(Faker.values(), Faker.choose())],
        label_opts=opts.LabelOpts(
            formatter=JsCode(
                "function(params){return params.value[1] +' : '+ params.value[2];}"
            )
        ),
    )
    .set_global_opts(
        title_opts=opts.TitleOpts(title="Scatter散點(diǎn)圖-多維度數(shù)據(jù)"),
        tooltip_opts=opts.TooltipOpts(
            formatter=JsCode(
                "function (params) {return params.name + ' : ' + params.value[2];}"
            )
        ),
        visualmap_opts=opts.VisualMapOpts(
            type_="color", max_=150, min_=20, dimension=1
        ),
    )
    .render("散點(diǎn)圖.html")
)

10、pyecharts繪制嵌套餅圖

import pyecharts.options as opts
from pyecharts.charts import Pie
from pyecharts.globals import ThemeType
list1  = [300,55,400,110]
attr1 = ["學(xué)習(xí)", "運(yùn)動(dòng)","休息", "娛樂"]
list2  = [40,160,45,35,80,400,35,60]
attr2 = ["閱讀", "上課", "運(yùn)動(dòng)", "討論", "編程", "睡覺","聽音樂", "玩手機(jī)"]

inner_data_pair = [list(z) for z in zip(attr1, list1)]
outer_data_pair = [list(z) for z in zip(attr2, list2)]
(
    Pie(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
    .add(
        series_name="時(shí)長占比",
        data_pair=inner_data_pair,
        radius=[0, "30%"],
        label_opts=opts.LabelOpts(position="inner"),
    )
    .add(
        series_name="時(shí)長占比",
        radius=["40%", "55%"],
        data_pair=outer_data_pair,
        label_opts=opts.LabelOpts(
            position="outside",
            formatter="{a|{a}}{abg|}\n{hr|}\n {b|: }{c}  {per|wppm3vysvbp%}  ",
            background_color="#eee",
            border_color="#aaa",
            border_width=1,
            border_radius=4,
            rich={
                "a": {"color": "#999", "lineHeight": 22, "align": "center"},
                "abg": {
                    "backgroundColor": "#e3e3e3",
                    "width": "100%",
                    "align": "right",
                    "height": 22,
                    "borderRadius": [4, 4, 0, 0],
                },
                "hr": {
                    "borderColor": "#aaa",
                    "width": "100%",
                    "borderWidth": 0.5,
                    "height": 0,
                },
                "b": {"fontSize": 16, "lineHeight": 33},
                "per": {
                    "color": "#eee",
                    "backgroundColor": "#334455",
                    "padding": [2, 4],
                    "borderRadius": 2,
                },
            },
        ),
    )
    .set_global_opts(legend_opts=opts.LegendOpts(pos_left="left", orient="vertical"))
    .set_series_opts(
        tooltip_opts=opts.TooltipOpts(
            trigger="item", formatter="{a} <br/>: {c} (wppm3vysvbp%)"
        )
    )
    .render("嵌套餅圖.html")
)

11、pyecharts繪制中國地圖

#導(dǎo)入模塊
from pyecharts import options as opts
from pyecharts.charts import Map
import random
# 設(shè)置商家A所存在的相關(guān)省份,并設(shè)置初始數(shù)量為0
ultraman = [
['四川', 0],
['臺灣', 0],
['新疆', 0],
['江西', 0],
['河南', 0],
['遼寧', 0],
['青海', 0],
['福建', 0],
['西藏', 0]
]

# 設(shè)置商家B存在的相關(guān)省份,并設(shè)置初始數(shù)量為0
monster = [
['廣東', 0],
['北京', 0],
['上海', 0],
['臺灣', 0],
['湖南', 0],
['浙江', 0],
['甘肅', 0],
['黑龍江', 0],
['江蘇', 0]
]
def data_filling(array):
    ''' 
     作用:給數(shù)組數(shù)據(jù)填充隨機(jī)數(shù)
    '''
    for i in array:
        # 隨機(jī)生成1到1000的隨機(jī)數(shù)
        i[1] = random.randint(1,1000)
data_filling(ultraman)
data_filling(monster)
def create_china_map():
    (
        Map()
        .add(
            series_name="商家A",
            data_pair=ultraman,
            maptype="china",
            # 是否默認(rèn)選中,默認(rèn)為True
            is_selected=True,
            # 是否啟用鼠標(biāo)滾輪縮放和拖動(dòng)平移,默認(rèn)為True
            is_roam=True,
            # 是否顯示圖形標(biāo)記,默認(rèn)為True
            is_map_symbol_show=False,
            # 圖元樣式配置
            itemstyle_opts={
                # 常規(guī)顯示
                "normal": {"areaColor": "white", "borderColor": "red"},
                # 強(qiáng)調(diào)顏色
                "emphasis": {"areaColor": "pink"}
            }
        )
        .add(
            series_name="商家B",
            data_pair=monster,
            maptype="china",
        )
        # 全局配置項(xiàng)
        .set_global_opts(
            # 設(shè)置標(biāo)題
            title_opts=opts.TitleOpts(title="中國地圖"),
            # 設(shè)置標(biāo)準(zhǔn)顯示
            visualmap_opts=opts.VisualMapOpts(max_=1000, is_piecewise=False)
        )
        # 系列配置項(xiàng)
        .set_series_opts(
            # 標(biāo)簽名稱顯示,默認(rèn)為True
            label_opts=opts.LabelOpts(is_show=True, color="blue")
        )
        # 生成本地html文件
        .render("中國地圖.html")
    )
    #調(diào)用自定義函數(shù)
create_china_map()

12、pyecharts繪制世界地圖

from pyecharts import options as opts
from pyecharts.charts import Map
import random
# 設(shè)置商家A所存在的相關(guān)國家,并設(shè)置初始數(shù)量為0
ultraman = [
['Russia', 0],
['China', 0],
['United States', 0],
['Australia', 0]
]
# 設(shè)置商家B存在的相關(guān)國家,并設(shè)置初始數(shù)量為0
monster = [
['India', 0],
['Canada', 0],
['France', 0],
['Brazil', 0]
]
def data_filling(array):
    for i in array:
        # 隨機(jī)生成1到1000的隨機(jī)數(shù)
        i[1] = random.randint(1,1000)
        print(i)

data_filling(ultraman)
data_filling(monster)

def create_world_map():
    '''
     作用:生成世界地圖
    '''
    (   # 大小設(shè)置
        Map()
        .add(
            series_name="商家A",
            data_pair=ultraman,
            maptype="world",
        )
        .add(
            series_name="商家B",
            data_pair=monster,
            maptype="world",
        )
        # 全局配置項(xiàng)
        .set_global_opts(
            # 設(shè)置標(biāo)題
            title_opts=opts.TitleOpts(title="世界地圖"),
            # 設(shè)置標(biāo)準(zhǔn)顯示
            visualmap_opts=opts.VisualMapOpts(max_=1000, is_piecewise=False),
        )
        # 系列配置項(xiàng)
        .set_series_opts(
            # 標(biāo)簽名稱顯示,默認(rèn)為True
            label_opts=opts.LabelOpts(is_show=False, color="blue")
        )
        # 生成本地html文件
        .render("世界地圖.html")
    )

create_world_map()

到此這篇關(guān)于pyecharts繪制各種數(shù)據(jù)可視化圖表案例附效果+代碼的文章就介紹到這了,更多相關(guān)pyecharts可視化圖表內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python 實(shí)現(xiàn)某個(gè)功能每隔一段時(shí)間被執(zhí)行一次的功能方法

    Python 實(shí)現(xiàn)某個(gè)功能每隔一段時(shí)間被執(zhí)行一次的功能方法

    今天小編就為大家分享一篇Python 實(shí)現(xiàn)某個(gè)功能每隔一段時(shí)間被執(zhí)行一次的功能方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-10-10
  • python實(shí)現(xiàn)感知機(jī)線性分類模型示例代碼

    python實(shí)現(xiàn)感知機(jī)線性分類模型示例代碼

    這篇文章主要給大家介紹了關(guān)于python實(shí)現(xiàn)感知機(jī)線性分類模型的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用python具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-06-06
  • Python循環(huán)取數(shù)組的值的方法實(shí)現(xiàn)

    Python循環(huán)取數(shù)組的值的方法實(shí)現(xiàn)

    本文主要介紹了兩種Python中遍歷數(shù)組的方法,for循環(huán)和索引,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-12-12
  • TensorFlow實(shí)現(xiàn)從txt文件讀取數(shù)據(jù)

    TensorFlow實(shí)現(xiàn)從txt文件讀取數(shù)據(jù)

    今天小編就為大家分享一篇TensorFlow實(shí)現(xiàn)從txt文件讀取數(shù)據(jù),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-02-02
  • Django中STATIC_ROOT和STATIC_URL及STATICFILES_DIRS淺析

    Django中STATIC_ROOT和STATIC_URL及STATICFILES_DIRS淺析

    這篇文章主要給大家介紹了關(guān)于Django中STATIC_ROOT和STATIC_URL及STATICFILES_DIRS的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧
    2018-05-05
  • WxPython界面如何用pubsub展示進(jìn)程工作的進(jìn)度條

    WxPython界面如何用pubsub展示進(jìn)程工作的進(jìn)度條

    這篇文章主要介紹了WxPython界面如何用pubsub展示進(jìn)程工作的進(jìn)度條,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-11-11
  • python并發(fā)執(zhí)行request請求的示例

    python并發(fā)執(zhí)行request請求的示例

    這篇文章主要介紹了python并發(fā)執(zhí)行request請求,我將為我們展示使用concurrent.futures.ThreadPoolExecutor和requests庫并發(fā)執(zhí)行HTTP請求的示例,需要的朋友可以參考下
    2024-06-06
  • python進(jìn)行TCP端口掃描的實(shí)現(xiàn)

    python進(jìn)行TCP端口掃描的實(shí)現(xiàn)

    這篇文章主要介紹了python進(jìn)行TCP端口掃描的實(shí)現(xiàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-12-12
  • 關(guān)于numpy.concatenate()函數(shù)的使用及說明

    關(guān)于numpy.concatenate()函數(shù)的使用及說明

    這篇文章主要介紹了關(guān)于numpy.concatenate()函數(shù)的使用及說明,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • Selenium之模擬登錄鐵路12306的示例代碼

    Selenium之模擬登錄鐵路12306的示例代碼

    這篇文章主要介紹了Selenium之模擬登錄鐵路12306的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07

最新評論

竹北市| 青岛市| 常山县| 义乌市| 尖扎县| 祁门县| 宜兴市| 赤水市| 犍为县| 昂仁县| 新津县| 如东县| 三江| 马龙县| 灵武市| 威海市| 冷水江市| 尼玛县| 靖远县| 清苑县| 金阳县| 根河市| 永州市| 宁海县| 和政县| 娄底市| 金堂县| 华宁县| 南投市| 哈巴河县| 都兰县| 博客| 土默特右旗| 始兴县| 成安县| 沁水县| 大庆市| 普兰店市| 寿阳县| 景宁| 荔波县|