当前位置: 首页 > news >正文

的网站开发工具厦门企业建站系统模板

的网站开发工具,厦门企业建站系统模板,经典模板网站建设,中国宁波网首页Pandas 数据可视化指南#xff1a;从散点图到面积图的全面展示 本文介绍了使用 Pandas 进行数据可视化的多种方法#xff0c;包括散点图、折线图、条形图、直方图、饼图和面积图等#xff0c;涵盖了常见的图表类型及其实现方式。通过提供详细的代码示例#xff0c;展示了如…Pandas 数据可视化指南从散点图到面积图的全面展示 本文介绍了使用 Pandas 进行数据可视化的多种方法包括散点图、折线图、条形图、直方图、饼图和面积图等涵盖了常见的图表类型及其实现方式。通过提供详细的代码示例展示了如何使用 Pandas 和 Matplotlib 快速创建不同类型的图表帮助读者轻松掌握数据可视化技术。这篇指南既适合初学者也为有经验的开发者提供了一些实用技巧帮助在数据分析中更直观地展示结果。 文章目录 Pandas 数据可视化指南从散点图到面积图的全面展示一 散点图Scatter二 折线图Plot简单折线图多折线图 三 条形图Bar垂直条形图堆叠条形图水平条形图 四 直方图Hist简单直方图重叠直方图 五 饼图Pie简单饼图多个饼图 六 面积图Area堆叠面积图同起点面积图 七 完整代码示例八 源码地址 导入库 在开始绘制图表之前我们首先导入必要的库 import numpy as np import pandas as pd import matplotlib.pyplot as plt一 散点图Scatter n 1024 # 数据量 # 创建数据框 df pd.DataFrame({x: np.random.normal(0, 1, n),y: np.random.normal(0, 1, n), }) # 使用 arctan2 函数计算颜色 color np.arctan2(df[y], df[x]) # 绘制散点图 df.plot.scatter(xx, yy, ccolor, s60, alpha0.5, cmaprainbow)二 折线图Plot 简单折线图 n 20 # 数据量 x np.linspace(-1, 1, n) y x * 2 0.4 np.random.normal(0, 0.3, n) # 创建数据框 df pd.DataFrame({x: x,y: y, }) # 绘制折线图 df.plot(xx, yy, alpha0.5, cr)多折线图 n 20 # 数据量 x np.linspace(-1, 1, n) y1 x * -1 - 0.1 np.random.normal(0, 0.3, n) y2 x * 2 0.4 np.random.normal(0, 0.3, n) # 创建数据框 df pd.DataFrame({x: x,y1: y1,y2: y2, }) # 绘制多折线图 df.plot(xx, y[y1, y2], alpha0.5)三 条形图Bar 垂直条形图 df pd.DataFrame(np.random.rand(5, 3), columns[a, b, c])df.plot.bar()堆叠条形图 df pd.DataFrame(np.random.rand(5, 3), columns[a, b, c])df.plot.bar(stackedTrue)水平条形图 df pd.DataFrame(np.random.rand(5, 3), columns[a, b, c])df.plot.barh()四 直方图Hist 简单直方图 df pd.DataFrame({a: np.random.randn(1000)}) df.plot.hist()重叠直方图 df pd.DataFrame({a: np.random.randn(1000) 1,b: np.random.randn(1000),c: np.random.randn(1000) - 4,} )df.plot.hist(alpha0.5, bins30) 五 饼图Pie 简单饼图 df pd.DataFrame({boss: np.random.rand(4)},index[meeting, supervise, teaching, team building],)df.plot.pie(yboss, figsize(7, 7))多个饼图 df pd.DataFrame({bigBoss: np.random.rand(4),smallBoss: np.random.rand(4),},index[meeting, supervise, teaching, team building], ) df.plot.pie(subplotsTrue, figsize(9, 9), legendFalse)六 面积图Area 堆叠面积图 # df pd.DataFrame(np.random.rand(10, 4),columns[a, b, c, d] ) df.plot.area()同起点面积图 # df pd.DataFrame(np.random.rand(10, 4),columns[a, b, c, d] ) df.plot.area(stackedFalse)详情见官方文档Pandas 可视化图表 七 完整代码示例 # This is a sample Python script.# Press ⌃R to execute it or replace it with your code. # Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings. import numpy as np import pandas as pd import matplotlib.pyplot as pltdef print_hi(name):# Use a breakpoint in the code line below to debug your script.print(fHi, {name}) # Press ⌘F8 to toggle the breakpoint.# 散点图Scattern 1024 # data sizedf pd.DataFrame({x: np.random.normal(0, 1, n),y: np.random.normal(0, 1, n),})color np.arctan2(df[y], df[x])df.plot.scatter(xx, yy, ccolor, s60, alpha.5, cmaprainbow)# 折线图Plotn 20 # data sizex np.linspace(-1, 1, n)y x * 2 0.4 np.random.normal(0, 0.3, n)df pd.DataFrame({x: x,y: y,})df.plot(xx, yy, alpha.5, cr)n 20 # data sizex np.linspace(-1, 1, n)y1 x * -1 - 0.1 np.random.normal(0, 0.3, n)y2 x * 2 0.4 np.random.normal(0, 0.3, n)df pd.DataFrame({x: x,y1: y1,y2: y2,})df.plot(xx, y[y1, y2], alpha.5)# 条形图Bardf pd.DataFrame(np.random.rand(5, 3), columns[a, b, c])df.plot.bar()df.plot.bar(stackedTrue)df.plot.barh()# 分布图Histdf pd.DataFrame({a: np.random.randn(1000)})df.plot.hist()df pd.DataFrame({a: np.random.randn(1000) 1,b: np.random.randn(1000),c: np.random.randn(1000) - 4,})df.plot.hist(alpha0.5, bins30)# 饼图Piedf pd.DataFrame({boss: np.random.rand(4)},index[meeting, supervise, teaching, team building],)df.plot.pie(yboss, figsize(7, 7))df pd.DataFrame({bigBoss: np.random.rand(4),smallBoss: np.random.rand(4),},index[meeting, supervise, teaching, team building],)df.plot.pie(subplotsTrue, figsize(9, 9), legendFalse)# 面积图Areadf pd.DataFrame(np.random.rand(10, 4),columns[a, b, c, d])df.plot.area()plt.show()df.plot.area(stackedFalse)plt.show()# https://pandas.pydata.org/pandas-docs/stable/user_guide/visualization.html# Press the green button in the gutter to run the script. if __name__ __main__:print_hi(绘制图表)# See PyCharm help at https://www.jetbrains.com/help/pycharm/ 复制粘贴并覆盖到你的 main.py 中运行运行结果如下。 Hi, 绘制图表八 源码地址 代码地址 国内看 Gitee 之 pandas/绘制图表.py 国外看 GitHub 之 pandas/绘制图表.py 引用 莫烦 Python
http://www.w-s-a.com/news/621392/

相关文章:

  • 石家庄做网站网络公司电子商务营销推广
  • 网站开发 前端专做婚礼logo的网站
  • 同创企业网站建设拖拽建设网站源码
  • wordpress调用网站标题网站页面排版
  • 哈尔滨营销网站建设电子商城网站开发要多少钱
  • 免费织梦导航网站模板下载地址自己建站网站
  • 获取网站访客qq号码代码做抽奖网站违法吗
  • 湖南大型网站建设公司排名偷网站源码直接建站
  • 网站建设周期规划北京网站设计必看刻
  • 如何做自己的在线作品网站深圳网站设计公司的
  • 网站开发外包公司wordpress最简单模板
  • 湖南省建设人力资源网站wordpress主机pfthost
  • 淮安软件园哪家做网站各网站特点
  • 网站长尾关键词排名软件重庆荣昌网站建设
  • 建个商城网站多少钱茂名专业网站建设
  • 开通公司网站免费的网站app下载
  • 跨境电商网站模板wordpress壁纸
  • 国内做网站网站代理电子商务网站建设与维护概述
  • 如何做地方网站推广沈阳网势科技有限公司
  • 哈尔滨网站优化技术涵江网站建设
  • 做网站搞笑口号wordpress全屏动画
  • 怎么可以建网站小程序代理项目
  • 怎样做软件网站哪个网站用帝国cms做的
  • 网站开发编程的工作方法wordpress dux-plus
  • 廊坊电子商务网站建设公司网站进不去qq空间
  • 南宁网站推广费用创意网页设计素材模板
  • 深圳技术支持 骏域网站建设wordpress 酒主题
  • 东莞网站建设+旅游网站改版数据来源表改怎么做
  • 手机端做的优秀的网站设计企业做网站大概多少钱
  • 优化网站使用体验手机网站解析域名