日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python 仪表盘 ppt_Python之pyecharts数据可视化,词云图,仪表盘!

發(fā)布時間:2024/1/8 python 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 仪表盘 ppt_Python之pyecharts数据可视化,词云图,仪表盘! 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

一、詞云圖

詞云就是通過形成關(guān)鍵詞云層或關(guān)鍵詞渲染,過濾掉大量的文本信息,對網(wǎng)絡(luò)文本中出現(xiàn)頻率較高的關(guān)鍵詞的視覺上的突出。

import jieba

import collections

import re

from pyecharts.charts import WordCloud

from pyecharts.globals import SymbolType

from pyecharts import options as opts

from pyecharts.globals import ThemeType, CurrentConfig

CurrentConfig.ONLINE_HOST = ‘D:/python/pyecharts-assets-master/assets/‘

with open(‘barrages.txt‘) as f:

data = f.read()

# 文本預(yù)處理 去除一些無用的字符 只提取出中文出來

new_data = re.findall(‘[u4e00-u9fa5]+‘, data, re.S) # 只要字符串中的中文

new_data = " ".join(new_data)

# 文本分詞--精確模式

seg_list_exact = jieba.cut(new_data, cut_all=False)

result_list = []

with open(‘stop_words.txt‘, encoding=‘utf-8‘) as f:

con = f.readlines()

stop_words = set()

for i in con:

i = i.replace("n", "") # 去掉讀取每一行數(shù)據(jù)的n

stop_words.add(i)

for word in seg_list_exact:

# 設(shè)置停用詞并去除單個詞

if word not in stop_words and len(word) > 1:

result_list.append(word)

print(result_list)

# 篩選后統(tǒng)計

word_counts = collections.Counter(result_list)

# 獲取前100最高頻的詞

word_counts_top100 = word_counts.most_common(100)

# 打印出來看看統(tǒng)計的詞頻

print(word_counts_top100)

# 鏈式調(diào)用

c = (

WordCloud(

init_opts=opts.InitOpts(width=‘1350px‘, height=‘750px‘, theme=ThemeType.MACARONS)

)

.add(

series_name="詞頻", # 系列名稱

data_pair=word_counts_top100, # 系列數(shù)據(jù)項 [(word1, count1), (word2, count2)]

word_size_range=[15, 108], # 單詞字體大小范圍

textstyle_opts=opts.TextStyleOpts( # 詞云圖文字的配置

font_family=‘KaiTi‘,

),

shape=SymbolType.DIAMOND, # 詞云圖輪廓,有 ‘circle‘, ‘cardioid‘, ‘diamond‘, ‘triangle-forward‘, ‘triangle‘, ‘pentagon‘, ‘star‘ 可選

pos_left=‘100‘, # 距離左側(cè)的距離

pos_top=‘50‘, # 距離頂部的距離

)

.set_global_opts(

title_opts=opts.TitleOpts( # 標題配置項

title=‘彈幕詞云圖‘,

title_textstyle_opts=opts.TextStyleOpts(

font_family=‘SimHei‘,

font_size=25,

color=‘black‘

),

pos_left=‘500‘,

pos_top=‘10‘,

),

tooltip_opts=opts.TooltipOpts( # 提示框配置項

is_show=True,

background_color=‘red‘,

border_color=‘yellow‘,

),

toolbox_opts=opts.ToolboxOpts( # 工具箱配置項

is_show=True,

orient=‘vertical‘,

)

)

.render(‘彈幕詞云圖.html‘)

運行效果如下:

二、儀表盤

from pyecharts.charts import Gauge

from pyecharts.globals import CurrentConfig

from pyecharts import options as opts

CurrentConfig.ONLINE_HOST = ‘D:/python/pyecharts-assets-master/assets/‘

c = (

Gauge()

.add(

series_name=‘業(yè)務(wù)指標‘, # 系列名稱,用于 tooltip 的顯示,legend 的圖例篩選。

data_pair=[[‘完成率‘, 88.8]], # 系列數(shù)據(jù)項,格式為 [(key1, value1), (key2, value2)]

radius=‘70%‘, # 儀表盤半徑,可以是相對于容器高寬中較小的一項的一半的百分比,也可以是絕對的數(shù)值。

axisline_opts=opts.AxisLineOpts(

linestyle_opts=opts.LineStyleOpts( # 坐標軸軸線配置項

color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")],

width=30,

)

),

title_label_opts=opts.LabelOpts( # 輪盤內(nèi)標題文本項標簽配置項

font_size=25, color=‘blue‘, font_family=‘KaiTi‘

)

)

.set_global_opts(

title_opts=opts.TitleOpts( # 標題配置項

title=‘儀表盤‘,

title_textstyle_opts=opts.TextStyleOpts(

font_size=25, font_family=‘SimHei‘,

color=‘black‘, font_weight=‘bold‘,

),

pos_left="410", pos_top="8",

),

legend_opts=opts.LegendOpts( # 圖例配置項

is_show=False

),

tooltip_opts=opts.TooltipOpts( # 提示框配置項

is_show=True,

formatter="{a}
{b} : {c}%",

)

)

.render(‘gauge.html‘)

)

運行效果如下:

三、水球圖

from pyecharts import options as opts

from pyecharts.charts import Grid, Liquid

from pyecharts.commons.utils import JsCode

from pyecharts.globals import CurrentConfig, ThemeType

CurrentConfig.ONLINE_HOST = ‘D:/python/pyecharts-assets-master/assets/‘

lq_1 = (

Liquid()

.add(

series_name=‘電量‘, # 系列名稱,用于 tooltip 的顯示,legend 的圖例篩選。

data=[0.25], # 系列數(shù)據(jù),格式為 [value1, value2, ....]

center=[‘60%‘, ‘50%‘],

# 水球外形,有‘ circle‘, ‘rect‘, ‘roundRect‘, ‘triangle‘, ‘diamond‘, ‘pin‘, ‘a(chǎn)rrow‘ 可選。

# 默認 ‘circle‘ 也可以為自定義的 SVG 路徑

shape=‘circle‘,

color=[‘yellow‘], # 波浪顏色 Optional[Sequence[str]] = None,

is_animation=True, # 是否顯示波浪動畫

is_outline_show=False, # 是否顯示邊框

)

.set_global_opts(title_opts=opts.TitleOpts(title=‘多個Liquid顯示‘))

)

lq_2 = (

Liquid()

.add(

series_name=‘數(shù)據(jù)精度‘,

data=[0.8866],

center=[‘25%‘, ‘50%‘],

label_opts=opts.LabelOpts(

font_size=50,

formatter=JsCode(

"""function (param) {

return (Math.floor(param.value * 10000) / 100) + ‘%‘;

}"""

),

position=‘inside‘

)

)

)

grid = Grid(init_opts=opts.InitOpts(theme=ThemeType.DARK)).add(lq_1, grid_opts=opts.GridOpts()).add(lq_2, grid_opts=opts.GridOpts())

grid.render("multiple_liquid.html")

運行效果如下:

很好玩把,想學(xué)嗎?想學(xué)就加群呀:1136192749

原文鏈接:https://www.cnblogs.com/A3535/p/13571700.html

本文來自網(wǎng)絡(luò),不代表手訊網(wǎng)立場。

總結(jié)

以上是生活随笔為你收集整理的python 仪表盘 ppt_Python之pyecharts数据可视化,词云图,仪表盘!的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。