pyecharts實現(xiàn)數(shù)據(jù)可視化
1.概述
pyecharts 是百度開源的,適用于數(shù)據(jù)可視化的工具,配置靈活,展示圖表相對美觀,順滑。

2.安裝
python3環(huán)境下的安裝:
pip3 install pyecharts
3.數(shù)據(jù)可視化代碼
3.1 柱狀圖
from pyecharts import options as opts
from pyecharts.charts import Bar
from pyecharts.faker import Faker
?
c = (
? ? Bar()
? ? .add_xaxis(Faker.choose())
? ? .add_yaxis("商家A", Faker.values(), stack="stack1")
? ? .add_yaxis("商家B", Faker.values(), stack="stack1")
? ? .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
? ? .set_global_opts(title_opts=opts.TitleOpts(title="Bar-堆疊數(shù)據(jù)(全部)"))
? ? .render("bar_stack0.html")
)執(zhí)行上述代碼,會在相對目錄生成mycharts.html文件,通過頁面打開。

3.2 折線圖
import pyecharts.options as opts
from pyecharts.charts import Line
?
"""
Gallery 使用 pyecharts 1.1.0
參考地址: https://echarts.apache.org/examples/editor.html?c=line-smooth
目前無法實現(xiàn)的功能:
暫無
"""
?
?
x_data = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
y_data = [820, 932, 901, 934, 1290, 1330, 1320]
?
?
(
? ? Line()
? ? .set_global_opts(
? ? ? ? tooltip_opts=opts.TooltipOpts(is_show=False),
? ? ? ? xaxis_opts=opts.AxisOpts(type_="category"),
? ? ? ? yaxis_opts=opts.AxisOpts(
? ? ? ? ? ? type_="value",
? ? ? ? ? ? axistick_opts=opts.AxisTickOpts(is_show=True),
? ? ? ? ? ? splitline_opts=opts.SplitLineOpts(is_show=True),
? ? ? ? ),
? ? )
? ? .add_xaxis(xaxis_data=x_data)
? ? .add_yaxis(
? ? ? ? series_name="",
? ? ? ? y_axis=y_data,
? ? ? ? symbol="emptyCircle",
? ? ? ? is_symbol_show=True,
? ? ? ? is_smooth=True,
? ? ? ? label_opts=opts.LabelOpts(is_show=False),
? ? )
? ? .render("smoothed_line_chart.html")
)
3.3 餅圖
from pyecharts import options as opts
from pyecharts.charts import Pie
from pyecharts.faker import Faker
?
c = (
? ? Pie()
? ? .add(
? ? ? ? "",
? ? ? ? [list(z) for z in zip(Faker.choose(), Faker.values())],
? ? ? ? radius=["40%", "75%"],
? ? )
? ? .set_global_opts(
? ? ? ? title_opts=opts.TitleOpts(title="Pie-Radius"),
? ? ? ? legend_opts=opts.LegendOpts(orient="vertical", pos_top="15%", pos_left="2%"),
? ? )
? ? .set_series_opts(label_opts=opts.LabelOpts(formatter=": {c}"))
? ? .render("pie_radius.html")
)

到此這篇關(guān)于pyecharts實現(xiàn)數(shù)據(jù)可視化的文章就介紹到這了,更多相關(guān)pyecharts數(shù)據(jù)可視化內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python 結(jié)巴分詞實現(xiàn)關(guān)鍵詞抽取分析
這篇文章主要介紹了Python 結(jié)巴分詞實現(xiàn)關(guān)鍵詞抽取分析,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-10-10
django admin管理工具自定義時間區(qū)間篩選器DateRangeFilter介紹
這篇文章主要介紹了django admin管理工具自定義時間區(qū)間篩選器DateRangeFilter介紹,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-05-05
Python 列表中的修改、添加和刪除元素的實現(xiàn)
這篇文章主要介紹了Python 列表中的修改、添加和刪除元素的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06
Python實現(xiàn)的單向循環(huán)鏈表功能示例
這篇文章主要介紹了Python實現(xiàn)的單向循環(huán)鏈表功能,簡單描述了單向循環(huán)鏈表的概念、原理并結(jié)合實例形式分析了Python定義與使用單向循環(huán)鏈表的相關(guān)操作技巧,需要的朋友可以參考下2017-11-11

