R:使用 Lattice 与 ggplot2 相比有何优缺点?

发布于 2024-08-31 15:16:15 字数 1431 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

醉酒的小男人 2024-09-07 15:16:17

喜欢 Roger Peng 在他的 ppt 中比较 Base/Lattice/gglot2 软件包时所说的话:
https://github.com/rdpeng/CourseraLectures/blob/master/ggplot2_part1.pptx

基础

  1. “艺术家调色板”模型
  2. 从空白画布开始,然后从那里开始构建
  3. 从绘图功能(或类似功能)开始
  4. 使用注释功能添加/修改(文本、线条、点、轴)

优点:

方便,反映了我们的使用方式考虑构建绘图和分析数据

缺点:

  1. 一旦绘图开始就无法返回(即调整边距);
  2. 需要提前计划
  3. 一旦创建了新的情节就很难“翻译”给其他人(没有图形“语言”)。绘图只是一系列 R 命令

格子

图是通过单个函数调用(xyplot、bwplot 等)创建的

优点:

  1. 对于调节绘图类型最有用:查看 y 在 z 的各个级别上如何随 x 变化
  2. 认为像边距/自动设置间距,因为一次指定整个绘图
  3. 适合在屏幕上放置许多绘图

缺点:

  1. 有时很难在单个函数调用中指定整个绘图
  2. 绘图中的注释不直观
  3. 使用面板函数和下标很难使用并且需要紧张的准备工作
  4. 一旦创建就无法“添加”到绘图中

ggplot2

优点:

  1. 区分基础和点阵之间的差异
  2. 自动处理间距、文本、标题,但也允许您通过“添加”进行注释
  3. 表面上与点阵相似,但通常更容易/更直观使用
  4. 默认模式可以为您提供多种选择(但您可以自定义!)

Love what Roger Peng said when comparing Base/Lattice/gglot2 packages in his ppt:
https://github.com/rdpeng/CourseraLectures/blob/master/ggplot2_part1.pptx

Base

  1. “Artist’s palette” model
  2. Start with blank canvas and build up from there
  3. Start with plot function (or similar)
  4. Use annotation functions to add/modify (text, lines, points, axis)

Pros:

Convenient, mirrors how we think of building plots and analyzing data

Cons:

  1. Can’t go back once plot has started (i.e. to adjust margins);
  2. need to plan in advance
  3. Difficult to “translate” to others once a new plot has been created (no graphical “language”). Plot is just a series of R commands

Lattice

Plots are created with a single function call (xyplot, bwplot, etc.)

Pros:

  1. Most useful for conditioning types of plots: Looking at how y changes with x across levels of z
  2. Thinks like margins/spacing set automatically because entire plot is specified at once
  3. Good for putting many many plots on a screen

Cons:

  1. Sometimes awkward to specify an entire plot in a single function call
  2. Annotation in plot is not intuitive
  3. Use of panel functions and subscripts difficult to wield and requires intense preparation
  4. Cannot “add” to the plot once it’s created

ggplot2

Pros:

  1. Split the difference between base and lattice
  2. Automatically deals with spacing, text, titles but also allows you to annotate by “adding”
  3. Superficial similarity to lattice but generally easier/more intuitive to use
  4. Default mode makes many choices for you (but you can customize!)
我做我的改变 2024-09-07 15:16:17

根据这篇文章,ggplot2 目前不支持真正的 3d 曲面:

ggplot2 版本的“Lattice:使用 R 进行多元数据可视化”中的图形

ggplot2 currently does not support true 3d surfaces, according to this post:

ggplot2 Version of Figures in “Lattice: Multivariate Data Visualization with R”

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文