詳解如何基于Pyecharts繪制常見的直角坐標(biāo)系圖表
1.直方圖
# -*-coding:utf-8 -*-
# @Time : 21:02
# @Author: 黃榮津
# @File : 1.直方圖.py
# @Software: PyCharm
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]
bar = (Bar()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
bar.render("1.直方圖.html")
2.折線圖
# -*-coding:utf-8 -*-
# @Time : 21:19
# @Author: 黃榮津
# @File : 2.折線圖.py
# @Software: PyCharm
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]
line = (Line()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
line.render("2.折線圖.html")
3.箱形圖
# -*-coding:utf-8 -*-
# @Time : 21:25
# @Author: 黃榮津
# @File : 3.箱型圖.py
# @Software: PyCharm
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [[random.randint(100, 150) for i in range(20)] for item in x_data]
class Box:
pass
box =( Boxplot()
.add_xaxis(x_data)
.add_yaxis("", (y_data))
)
box.render("3.箱型圖.html")
4.散點圖
# -*-coding:utf-8 -*-
# @Time : 21:58
# @Author: 黃榮津
# @File : 4.散點圖.py
# @Software: PyCharm
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]
Scatter=(Scatter()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
Scatter.render("4.散點圖.html")
5.帶漣漪效果散點圖
# -*-coding:utf-8 -*-
# @Time : 22:23
# @Author: 黃榮津
# @File : 5.帶漣漪效果散點圖.py
# @Software: PyCharm
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]
effectScatter = (EffectScatter()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
effectScatter.render("5.帶漣漪效果散點圖.html")
6.k線圖
# -*-coding:utf-8 -*-
# @Time : 22:27
# @Author: 黃榮津
# @File : 6.k線圖.py
# @Software: PyCharm
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
date_list = ["2022/4/{}".format(i + 1) for i in range(30)]
y_data = [[random.randint(200, 350) for i in range(20)] for item in date_list]
kline = (Kline()
.add_xaxis(date_list)
.add_yaxis('', y_data)
)
kline.render("6.k線圖.html")
7.熱力圖
# -*-coding:utf-8 -*-
# @Time : 22:36
# @Author: 黃榮津
# @File : 7.熱力圖.py
# @Software: PyCharm
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
data = [[i, j, random.randint(0, 100)] for i in range(24) for j in range(7)]
hour_list = [str(i) for i in range(24)]
week_list = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
heat = (HeatMap()
.add_xaxis(hour_list)
.add_yaxis("", week_list, data)
)
heat.render("7.熱力圖.html")
8.象型圖
# -*-coding:utf-8 -*-
# @Time : 22:46
# @Author: 黃榮津
# @File : 8.象型圖.py
# @Software: PyCharm
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 33]
pictorialBar = (PictorialBar()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
pictorialBar.render("8.象型圖.html")
9.層疊圖
# -*-coding:utf-8 -*-
# @Time : 23:02
# @Author: 黃榮津
# @File : 9.層疊圖.py
# @Software: PyCharm
from pyecharts.charts import *
from pyecharts.components import Table
from pyecharts import options as opts
from pyecharts.commons.utils import JsCode
import random
import datetime
from pyecharts.globals import CurrentConfig
CurrentConfig.ONLINE_HOST = "https://cdn.kesci.com/lib/pyecharts_assets/"
x_data = ['python', 'java', 'c','c++', 'R', 'excel']
y_data = [143, 123, 69, 107, 90, 73]
bar = (Bar()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
line = (Line()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
overlap = bar.overlap(line) #利用第一個圖表為基礎(chǔ),往后的數(shù)據(jù)都將會畫在第一個圖表上
overlap.render("9.層疊圖.html")
總結(jié)
到此這篇關(guān)于如何基于Pyecharts繪制常見的直角坐標(biāo)系圖表的文章就介紹到這了,更多相關(guān)Pyecharts繪制直角坐標(biāo)系圖表內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Python數(shù)據(jù)可視化 pyecharts實現(xiàn)各種統(tǒng)計圖表過程詳解
- python的pyecharts繪制各種圖表詳細(附代碼)
- 一文教你用Pyecharts做交互圖表
- Python數(shù)據(jù)可視化之基于pyecharts實現(xiàn)的地理圖表的繪制
- Python+pyecharts繪制交互式可視化圖表
- Python使用pyecharts控件繪制圖表
- 教你用pyecharts繪制各種圖表案例(效果+代碼)
- Python繪制地理圖表可視化神器pyecharts
- Python可視化神器pyecharts繪制地理圖表
- Python可視化神器pyecharts之繪制地理圖表練習(xí)
- Pyecharts之特殊圖表的實現(xiàn)示例
相關(guān)文章
使用Python實現(xiàn)為PDF文檔設(shè)置和移除密碼
在數(shù)字化時代,文檔的安全性變得越來越重要,特別是對于包含敏感信息的PDF文件,所以本文主要來和大家介紹一下如何使用Python實現(xiàn)為PDF文檔設(shè)置和移除密碼,需要的可以參考下2024-03-03
Pytorch加載數(shù)據(jù)集的方式總結(jié)及補充
Pytorch自定義數(shù)據(jù)集方法,應(yīng)該是用pytorch做算法的最基本的東西,下面這篇文章主要給大家介紹了關(guān)于Pytorch加載數(shù)據(jù)集的方式總結(jié)及補充,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2022-11-11
Python實現(xiàn)去除圖片中指定顏色的像素功能示例
這篇文章主要介紹了Python實現(xiàn)去除圖片中指定顏色的像素功能,結(jié)合具體實例形式分析了Python基于pil與cv2模塊的圖形載入、運算、轉(zhuǎn)換等相關(guān)操作技巧,需要的朋友可以參考下2019-04-04
PIL.Image.open和cv2.imread的比較與相互轉(zhuǎn)換的方法
這篇文章主要介紹了PIL.Image.open和cv2.imread的比較與相互轉(zhuǎn)換的方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06
Python中卷積神經(jīng)網(wǎng)絡(luò)(CNN)入門教程分分享
卷積神經(jīng)網(wǎng)絡(luò)(Convolutional Neural Networks, CNN)是一類特別適用于處理圖像數(shù)據(jù)的深度學(xué)習(xí)模型,本文介紹了如何使用Keras創(chuàng)建一個簡單的CNN模型,并用它對手寫數(shù)字進行分類,需要的可以參考一下2023-05-05
Pytorch:dtype不一致問題(expected dtype Double but&
這篇文章主要介紹了Pytorch:dtype不一致問題(expected dtype Double but got dtype Float),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02
Python使用melt和pivot實現(xiàn)DataFrame格式轉(zhuǎn)換
在數(shù)據(jù)處理與分析中,經(jīng)常遇到數(shù)據(jù)需要進行格式轉(zhuǎn)換的情況,例如將數(shù)據(jù)從寬表格式轉(zhuǎn)換為長表格式,或?qū)?shù)據(jù)重新分組匯總,Pandas提供了豐富的reshape操作,尤其是melt和pivot這兩個函數(shù),使得DataFrame可以在寬表與長表之間高效轉(zhuǎn)換,本文介紹的非常詳細,需要的朋友可以參考下2025-01-01
Python趣味編程實現(xiàn)手繪風(fēng)視頻示例
本文與計算機視覺相關(guān),使用Python將圖片由自然風(fēng)轉(zhuǎn)化為手繪風(fēng),期間未對圖片進行任何預(yù)處理、后處理;代碼中只借助了兩個常見庫,核心計算由Numpy負責(zé) ,Pillow 負責(zé)圖片讀寫2021-10-10

