好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > 利用Python進行數(shù)據(jù)可視化的實例代碼

利用Python進行數(shù)據(jù)可視化的實例代碼

熱門標簽:銀川電話機器人電話 企業(yè)微信地圖標注 萊蕪電信外呼系統(tǒng) 怎么辦理400客服電話 B52系統(tǒng)電梯外呼顯示E7 鶴壁手機自動外呼系統(tǒng)違法嗎 沈陽防封電銷電話卡 高德地圖標注收入咋樣 地圖標注多個

前言

前面寫過一篇用Python制作PPT的博客,感興趣的可以參考

用Python制作PPT

這篇是關(guān)于用Python進行數(shù)據(jù)可視化的,準備作為一個長貼,隨時更新有價值的Python可視化用例,都是網(wǎng)上搜集來的,與君共享,本文所有測試均基于Python3.

首先搭建環(huán)境

$pip install pyecharts -U
$pip install echarts-themes-pypkg
$pip install snapshot_selenium
$pip install echarts-countries-pypkg
$pip install echarts-cities-pypkg
$pip install echarts-china-provinces-pypkg
$pip install echarts-china-cities-pypkg
$pip install echarts-china-counties-pypkg
$pip install echarts-china-misc-pypkg
$pip install echarts-united-kingdom-pypkg
$pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyecharts
$git clone https://github.com/pyecharts/pyecharts.git
$cd pyecharts/
$pip install -r requirements.txt
$python setup.py install
 

一頓操作下來,該裝的不該裝的都裝上了,多裝一些包沒壞處,說不定哪天就用上了呢

實例代碼

例子1:

from pyecharts.charts import Bar
from pyecharts import options as opts
 
bar = (
    Bar()
    .add_xaxis(["chenshan", "maoyi", "longdai", "kuzi", "fengyi", "gaogenxie", "wazi"])
    .add_yaxis("storeA", [114, 55, 27, 101, 125, 27, 105])
    .add_yaxis("storeB", [57, 134, 137, 129, 145, 60, 49])
    .set_global_opts(title_opts=opts.TitleOpts(title="sales"))
)
#bar.render_notebook()
bar.render()

render():默認將會在根目錄下生成一個 render.html 的文件,支持 path 參數(shù),設(shè)置文件保存位置,如 render("./xx/xxx.html").

結(jié)果是以網(wǎng)頁的形式輸出的,執(zhí)行后,在當前目錄下生成render.html,用瀏覽器打開,最好事先安裝chrome瀏覽器.

 例子2:

from pyecharts import options as opts
from pyecharts.charts import Pie
from pyecharts.faker import Faker
 
pie = (
    Pie()
    .add("", [list(z) for z in zip(Faker.choose(), Faker.values())])
    .set_colors(["blue", "green", "yellow", "red", "pink", "orange", "purple"])
    .set_global_opts(title_opts=opts.TitleOpts(title="Pie-設(shè)置顏色"))
    .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
)
 
pie.render()

 例子3:

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Faker
 
c = (
    Line()
    .add_xaxis(Faker.choose())
    .add_yaxis("storeA", Faker.values(), is_smooth=True)
    .add_yaxis("storeB", Faker.values(), is_smooth=True)
    .set_global_opts(title_opts=opts.TitleOpts(title="Line-smooth"))
)
c.render()

 例子4:

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],
]
 
 
k = (
    Kline()
    .add_xaxis(["2017/7/{}".format(i + 1) for i in range(31)])
    .add_yaxis("k-line", data)
    .set_global_opts(
        yaxis_opts=opts.AxisOpts(is_scale=True),
        xaxis_opts=opts.AxisOpts(is_scale=True),
        title_opts=opts.TitleOpts(title="Kline-examples"),
    )
 
)
k.render()

 例子5: 

from pyecharts import options as opts
from pyecharts.charts import Gauge
 
g = (
    Gauge()
    .add("", [("complete", 66.6)])
    .set_global_opts(title_opts=opts.TitleOpts(title="Gauge-basic examples"))
)
 
g.render()

例子6:

from pyecharts import options as opts
from pyecharts.charts import Bar
 
(
    Bar()
    .add_xaxis(
        [
            "名字很長的X軸標簽1",
            "名字很長的X軸標簽2",
            "名字很長的X軸標簽3",
            "名字很長的X軸標簽4",
            "名字很長的X軸標簽5",
            "名字很長的X軸標簽6",
        ]
    )
    .add_yaxis("商家A", [10, 20, 30, 40, 50, 40])
    .add_yaxis("商家B", [20, 10, 40, 30, 40, 50])
    .set_global_opts(
        xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=-15)),
        title_opts=opts.TitleOpts(title="Bar-旋轉(zhuǎn)X軸標簽", subtitle="解決標簽名字過長的問題"),
    )
    .render()
)

from pyecharts import options as opts
from pyecharts.faker import Faker
from pyecharts.charts import Page, Pie
l1 = ['aa','bb','cc','dd','ee']
num =[10,20,15,25,30]
c = (
        Pie()
        .add(
            "",
            [list(z) for z in zip(l1, num)],
            radius=["40%", "75%"],   # 圓環(huán)的粗細和大小
        )
        .set_global_opts(
            title_opts=opts.TitleOpts(title="Pie-Radius"),
            legend_opts=opts.LegendOpts(
                orient="vertical", pos_top="5%", pos_left="2%"  # 左面比例尺
            ),
        )
        .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}: {c}"))
    )
c.render()

from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Page, Pie
l1 = ['aa','bb','cc','dd','ee']
num =[10,20,15,25,30]
c = (
        Pie()
        .add(
            "",
            [list(z) for z in zip(l1, num)],
            radius=["40%", "55%"],
            label_opts=opts.LabelOpts(
                position="outside",
                formatter="{a|{a}}{abg|} {hr|} {b|{b}: }{c}  {per|lllljh1%}  ",
                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(title_opts=opts.TitleOpts(title="Pie-富文本示例"))
    )
c.render()

from pyecharts import options as opts
from pyecharts.charts import Line, Bar, Grid
bar = (
    Bar()
    .add_xaxis(["襯衫", "毛衣", "領(lǐng)帶", "褲子", "風衣", "高跟鞋", "襪子"])
    .add_yaxis("商家A", [114, 55, 27, 101, 125, 27, 105])
    .add_yaxis("商家B", [57, 134, 137, 129, 145, 60, 49])
    .set_global_opts(title_opts=opts.TitleOpts(title="運維之路"),)
)
week_name_list = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
high_temperature = [11, 11, 15, 13, 12, 13, 10]
low_temperature = [1, -2, 2, 5, 3, 2, 0]
line2 = (
    Line(init_opts=opts.InitOpts(width="1600px", height="800px"))
    .add_xaxis(xaxis_data=week_name_list)
    .add_yaxis(
        series_name="最高氣溫",
        y_axis=high_temperature,
        markpoint_opts=opts.MarkPointOpts(
            data=[
                opts.MarkPointItem(type_="max", name="最大值"),
                opts.MarkPointItem(type_="min", name="最小值"),
            ]
        ),
        markline_opts=opts.MarkLineOpts(
            data=[opts.MarkLineItem(type_="average", name="平均值")]
        ),
    )
    .add_yaxis(
        series_name="最低氣溫",
        y_axis=low_temperature,
        markpoint_opts=opts.MarkPointOpts(
            data=[opts.MarkPointItem(value=-2, name="周最低", x=1, y=-1.5)]
        ),
        markline_opts=opts.MarkLineOpts(
            data=[
                opts.MarkLineItem(type_="average", name="平均值"),
                opts.MarkLineItem(symbol="none", x="90%", y="max"),
                opts.MarkLineItem(symbol="circle", type_="max", name="最高點"),
            ]
        ),
    )
    .set_global_opts(
        #title_opts=opts.TitleOpts(title="氣溫變化", subtitle="純屬虛構(gòu)"),
        tooltip_opts=opts.TooltipOpts(trigger="axis"),
        toolbox_opts=opts.ToolboxOpts(is_show=True),
        xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),
        #legend_opts=opts.LegendOpts(pos_left="right"),
    )
    #.render("temperature_change_line_chart.html")
)
# 最后的 Grid
#grid_chart = Grid(init_opts=opts.InitOpts(width="1400px", height="800px"))
grid_chart = Grid()
grid_chart.add(
    bar,
    grid_opts=opts.GridOpts(
        pos_left="3%", pos_right="1%", height="20%"
    ),
)
# wr
grid_chart.add(
    line2,
    grid_opts=opts.GridOpts(
        pos_left="3%", pos_right="1%", pos_top="40%", height="35%"
    ),
)
#grid_chart.render("professional_kline_chart.html")
grid_chart.render()

from pyecharts import options as opts
from pyecharts.charts import Radar
v1=[[83, 92, 87, 49, 89, 86]]  # 數(shù)據(jù)必須為二維數(shù)組,否則會集中一個指示器顯示
v2=[[88, 95, 66, 43, 86, 96]]
v3=[[80, 92, 87, 58, 78, 81]]
radar1=(
    Radar()
    .add_schema(# 添加schema架構(gòu)
        schema=[
            opts.RadarIndicatorItem(name='傳球',max_=100),# 設(shè)置指示器名稱和最大值
            opts.RadarIndicatorItem(name='射門',max_=100),
            opts.RadarIndicatorItem(name='身體',max_=100),
            opts.RadarIndicatorItem(name='防守',max_=100),
            opts.RadarIndicatorItem(name='速度',max_=100),
            opts.RadarIndicatorItem(name='盤帶',max_=100),
        ]
    )
    .add('羅納爾多',v1,color="#f9713c") # 添加一條數(shù)據(jù),參數(shù)1為數(shù)據(jù)名,參數(shù)2為數(shù)據(jù),參數(shù)3為顏色
    .add('梅西',v2,color="#4169E1") 
    .add('蘇亞雷斯',v3,color="#00BFFF") 
    .set_global_opts(title_opts=opts.TitleOpts(title='雷達圖'),)
)
radar1.render()

import math
import random
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Page, Polar
c = (
        Polar()
        .add_schema(
            angleaxis_opts=opts.AngleAxisOpts(data=Faker.week, type_="category")
        )
        .add("A", [1, 2, 3, 4, 3, 5, 1], type_="bar", stack="stack0")
        .add("B", [2, 4, 6, 1, 2, 3, 1], type_="bar", stack="stack0")
        .add("C", [1, 2, 3, 4, 1, 2, 5], type_="bar", stack="stack0")
        .set_global_opts(title_opts=opts.TitleOpts(title="Polar-AngleAxis"))
    )
c.render()

import math
import random
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Page, Polar
data = [(i, random.randint(1, 100)) for i in range(10)]
c = (
        Polar()
        .add("", data, type_="effectScatter",
             effect_opts=opts.EffectOpts(scale=10, period=5),
             label_opts=opts.LabelOpts(is_show=False))
        #  type默認為"line",
        #  "effectScatter",scatter,bar
        .set_global_opts(title_opts=opts.TitleOpts(title="Polar-Scatter0"))
)
c.render()

import math
import random
from pyecharts.faker import Faker
from pyecharts import options as opts
from pyecharts.charts import Page, Polar
c = (
        Polar()
        .add_schema(
            radiusaxis_opts=opts.RadiusAxisOpts(data=Faker.week, type_="category")
        )
        .add("A", [1, 2, 3, 4, 3, 5, 1], type_="bar", stack="stack0")
        .add("B", [2, 4, 6, 1, 2, 3, 1], type_="bar", stack="stack0")
        .add("C", [1, 2, 3, 4, 1, 2, 5], type_="bar", stack="stack0")
        .set_global_opts(title_opts=opts.TitleOpts(title="Polar-RadiusAxis"))
)
c.render()

from pyecharts import options as opts
from pyecharts.charts import Liquid, Page
from pyecharts.globals import SymbolType
 
c = (
        Liquid()
        .add("lq", [0.61, 0.7],shape='rect',is_outline_show=False)
        # 水球外形,有' circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow' 可選。
        # 默認 'circle'。也可以為自定義的 SVG 路徑。
        #is_outline_show設(shè)置邊框
        .set_global_opts(title_opts=opts.TitleOpts(title="Liquid-基本示例"))
)
c.render()

散點圖:

from pyecharts.charts import Scatter
import pyecharts.options as opts
 
female_height = [161.2,167.5,159.5,157,155.8,170,159.1,166,176.2,160.2,172.5,170.9,172.9,153.4,160,147.2,168.2,175,157,167.6,159.5,175,166.8,176.5,170.2,]
female_weight = [51.6,59,49.2,63,53.6,59,47.6,69.8,66.8,75.2,55.2,54.2,62.5,42,50,49.8,49.2,73.2,47.8,68.8,50.6,82.5,57.2,87.8,72.8,54.5,]
 
male_height = [174 ,175.3 ,193.5 ,186.5 ,187.2 ,181.5 ,184 ,184.5 ,175 ,184 ,180 ,177.8 ,192 ,176 ,174 ,184 ,192.7 ,171.5 ,173 ,176 ,176 ,180.5 ,172.7 ,176 ,173.5 ,178 ,]
male_weight = [65.6 ,71.8 ,80.7 ,72.6 ,78.8 ,74.8 ,86.4 ,78.4 ,62 ,81.6 ,76.6 ,83.6 ,90 ,74.6 ,71 ,79.6 ,93.8 ,70 ,72.4 ,85.9 ,78.8 ,77.8 ,66.2 ,86.4 ,81.8 ,89.6 ,]
 
scatter = Scatter()
scatter.add_xaxis(female_height)
scatter.add_xaxis(male_height)
scatter.add_yaxis("female", female_weight, symbol_size=15) #散點大小
scatter.add_yaxis("male", male_weight, symbol_size=15) #散點大小
scatter.set_global_opts(title_opts=opts.TitleOpts(title="身高體重分布"),
                        xaxis_opts=opts.AxisOpts(
                            type_ = "value", # 設(shè)置x軸為數(shù)值軸
                            splitline_opts=opts.SplitLineOpts(is_show = True)), # x軸分割線
                        yaxis_opts=opts.AxisOpts(splitline_opts=opts.SplitLineOpts(is_show=True))# y軸分割線
                        )
scatter.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
scatter.render("./html/scatter_base.html")

總結(jié)

到此這篇關(guān)于利用Python進行數(shù)據(jù)可視化的文章就介紹到這了,更多相關(guān)Python數(shù)據(jù)可視化內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • python數(shù)據(jù)可視化之matplotlib.pyplot基礎(chǔ)以及折線圖
  • 淺談哪個Python庫才最適合做數(shù)據(jù)可視化
  • python數(shù)據(jù)可視化plt庫實例詳解
  • 學會Python數(shù)據(jù)可視化必須嘗試這7個庫
  • Python中seaborn庫之countplot的數(shù)據(jù)可視化使用
  • python實現(xiàn)股票歷史數(shù)據(jù)可視化分析案例
  • Python數(shù)據(jù)可視化之基于pyecharts實現(xiàn)的地理圖表的繪制
  • Python爬蟲實戰(zhàn)之爬取京東商品數(shù)據(jù)并實實現(xiàn)數(shù)據(jù)可視化
  • Python數(shù)據(jù)可視化之用Matplotlib繪制常用圖形
  • Python數(shù)據(jù)可視化之繪制柱狀圖和條形圖
  • python用pyecharts實現(xiàn)地圖數(shù)據(jù)可視化
  • python數(shù)據(jù)可視化 – 利用Bokeh和Bottle.py在網(wǎng)頁上展示你的數(shù)據(jù)

標簽:葫蘆島 銀川 安慶 三亞 烏魯木齊 呼倫貝爾 湘西 呼倫貝爾

巨人網(wǎng)絡(luò)通訊聲明:本文標題《利用Python進行數(shù)據(jù)可視化的實例代碼》,本文關(guān)鍵詞  利用,Python,進行,數(shù)據(jù),可視化,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《利用Python進行數(shù)據(jù)可視化的實例代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于利用Python進行數(shù)據(jù)可視化的實例代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 啪啪tv| 国产清纯白嫩大学生正在播放| 亚洲AV无码刮码在线看视色| 国产日韩精品视频一区二区| 久播影院免费理论片成年看| 成人久久久精品乱码一区二区三区| 色婷婷色综合缴情在线| 控制高潮边缘控制排泄| 性激烈的欧美三级视频试看| 闺蜜嗯啊啪啪厨房| 少妇被大狼拘躁A片免费| 阧阴破解版的程序| 国产精品无码亚洲欧美在线| xyx性爽欧美视频| 717秋霞三级good在线观看| 中文字幕在线导航| 麻豆91在线播放| 欧美激情一区二区三区中文字幕| 91麻豆苏语棠在线观看| 被强(H)| 百合(h)辣文| xx69xx18一50hd| 校花?一开让我爽一夜| 上司人妻互换HD无码中文字幕| 美女视频黄全免费的| 翁虹情难自禁三级在线观看| 欲女十八春三级| 教育| 性做久久久久久免费观看软件 | 亚洲欧美日韩中字综合| 在线视频三区| 8x8ⅹ国产精品一区二区| 老女人bbb| 成人做爰高潮片免费看直播蜜臀| 嗯啊好舒服| 校园男男高h小黄文| 日韩欧美久久| www.91av| 那两瓣越来越大还变黑怎么恢复 | 99ri国产精品无码色欲| 男女XXOO啪啪gif动态图|