1说明: 1。1HvPlot基于HoloViews的pandas、dask、streamz和xarray高级绘图API。 1。2HvPlot就是一个python高级数据可视化图库。 1。3其实就是基于boken的,一行代码搞定的数据可视化基本作图。 1。4本次代码是基于微软编辑器vscode,源代码基于jupyter的; 1。5顺带复习pandas的读取csv文件,更具有实际操作特性。 2准备: 2。1官网:https:www。cnpython。compypihvplothttps:github。comholovizhvplot数据来源这个包 2。2环境: 华为笔记本电脑、深度deepinlinux操作系统、谷歌浏览器、python3。8和微软vscode编辑器。 2。3安装:pipinstallhvplot本机安装sudopip3。8installhvplot本机推荐国内源安装sudopip3。8installihttps:mirrors。aliyun。compypisimplehvplot本机附带安装sudopip3。8installintakesudopip3。8installihttps:mirrors。aliyun。compypisimpleintake 2。4软连接: 2。4。1报警:WARNING:Thescriptcolorcetisinstalledinusrlocalpython3。8binwhichisnotonPATH。ConsideraddingthisdirectorytoPATHor,ifyouprefertosuppressthiswarning,usenowarnscriptlocation。WARNING:Thescripthvplotisinstalledinusrlocalpython3。8binwhichisnotonPATH。ConsideraddingthisdirectorytoPATHor,ifyouprefertosuppressthiswarning,usenowarnscriptlocation。WARNING:Thescriptsintakeandintakeserverareinstalledinusrlocalpython3。8binwhichisnotonPATH。ConsideraddingthisdirectorytoPATHor,ifyouprefertosuppressthiswarning,usenowarnscriptlocation。 2。4。2建议建立软连接:本机未进行软连接也行,必要时如下sudolnsusrlocalpython3。8binhvplotusrbinhvplot 3注意: 3。1数据集:crime。csv,是来源github的包,位于这个位置: hvplotmasterexamplesdatacrime。csv,我将其放在指定位置。 3。2修改源代码,用微软编辑器运行,自动打开浏览器,在网页上显示,支持中文,超级简单,基本上一行核心代码即可。 3。3本代码为注释版,里面有详细的讲解。 4折线图: 4。1代码:line线图importhvplotashvimporthvplot。pandasashvpdimportpandasaspd调用pandas读取csv数据dfpd。readcsv(homexgjDesktophvplotcrime。csv)注意hvplot。line是调用hvplot。pandas这个包1组数据的比较方法一:hvplot。line折线图xxdf。hvplot。line(xYear,yViolentCrimerate)方法二:kindline折线图3组数据xxdf。hvplot(xYear,y〔ViolentCrimerate,Robberyrate,Burglaryrate〕,valuelabelRate(per100kpeople),kindline)浏览器展示xx图表hv。show(xx) 4。2操作和效果图: 5散点图: 5。1代码:importhvplotashvimporthvplot。pandasashvpdimportpandasaspd调用pandas读取csv数据dfpd。readcsv(homexgjDesktophvplotcrime。csv)注意hvplot。scatter是调用hvplot。pandas这个包xxdf。hvplot。scatter(xYear,yViolentCrimerate)1组数据xxdf。hvplot(xYear,yViolentCrimerate,kindscatter)3组数据xxdf。hvplot(xYear,y〔ViolentCrimerate,Robberyrate,Burglaryrate〕,valuelabelRate(per100kpeople),kindscatter)浏览器展示xx图表hv。show(xx) 5。2效果图: 6柱状图: 6。1代码:importhvplotashvimporthvplot。pandasashvpdimportpandasaspd调用pandas读取csv数据dfpd。readcsv(homexgjDesktophvplotcrime。csv)取前10行数据,由于数据较多dddf。head(10)3组数据xxdd。hvplot(xYear,y〔ViolentCrimerate,Robberyrate,Burglaryrate〕,valuelabelRate(per100kpeople),kindbar)浏览器展示xx图表hv。show(xx) 6。2效果图: 7hexbin: 7。1代码:importhvplotashvimporthvplot。pandasashvpdimportpandasaspd调用pandas读取csv数据dfpd。readcsv(homexgjDesktophvplotcrime。csv)只能一组数据展示xxdf。hvplot。hexbin(xYear,yViolentCrimerate)浏览器展示xx图表hv。show(xx) 7。2效果图: 8subplots: 8。1代码:importhvplotashvimporthvplot。pandasashvpdimportpandasaspd调用pandas读取csv数据dfpd。readcsv(homexgjDesktophvplotcrime。csv)3组数据,一个图xxdf。hvplot(xYear,y〔Burglaryrate,ViolentCrimerate,Robberyrate〕,valuelabelRate)3个子图subplotsxxdf。hvplot(xYear,y〔Burglaryrate,ViolentCrimerate,Robberyrate〕,valuelabelRate,subplotsTrue,width300,height200)浏览器展示xx图表hv。show(xx) 8。2效果图: 9附带2个gif: 9。1networkx 9。1。1需要安装这个模块:pipinstallnetworkx 9。1。2代码:importnetworkxasnximporthvplot。networkxashvnxGnx。karateclubgraph()xxhvnx。drawspring(G,labelsclub,fontsize10pt,nodecolorclub,cmapCategory10,width500,height500)hvnx。show(xx) 9。1。3效果图: 9。2Streaming。ipynb 9。2。1代码省略。基于jupyter。 9。2。2需安装:sudopipinstallihttps:mirrors。aliyun。compypisimplestreamz本机安装sudopip3。8installihttps:mirrors。aliyun。compypisimplestreamz 9。2。2效果图: 自己整理并分享出来 喜欢的人,请点赞、关注、评论、转发和收藏。