Windows 下 R 图形中的抗锯齿(根据 Mac)

发布于 2024-11-08 03:31:14 字数 577 浏览 6 评论 0原文

有没有办法从 Windows 版本的 R 中绘制抗锯齿图形?正如您从下面的两个版本中看到的,Mac 版本的 R 打印图形抗锯齿.... Mac Version

....虽然 Windows 版本对文本进行抗锯齿处理,但它不会对实际图形进行抗锯齿处理,从立管点和网格可以看出: Windows Version

顺便说一句,这是代码:

library(scatterplot3d) 
attach(mtcars) 
s3d <-scatterplot3d(wt,disp,mpg, pch=16, highlight.3d=TRUE,
  type="h", main="3D Scatterplot")
fit <- lm(mpg ~ wt+disp) 
s3d$plane3d(fit)

我需要尽可能高的质量来发布网页。我正在运行 Windows 7 并从 RBloomberg 提取数据,该数据仅在 Windows 下运行。

is there a way to plot anti-aliased graphics from the Windows version of R? As you can see from the two versions below the Mac version of R prints graphics anti aliased....
Mac Version

....whereas while the Windows version anti-aliases text, it does not anti-alias the actual graphic, as can be seen from the riser points, and the grid:
Windows Version

Here is the code by the way:

library(scatterplot3d) 
attach(mtcars) 
s3d <-scatterplot3d(wt,disp,mpg, pch=16, highlight.3d=TRUE,
  type="h", main="3D Scatterplot")
fit <- lm(mpg ~ wt+disp) 
s3d$plane3d(fit)

I need the highest quality possible, for web page publication. I am running Windows 7 and pulling data from RBloomberg, which only works under Windows.

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

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

发布评论

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

评论(3

无所的.畏惧 2024-11-15 03:31:14

这可能取决于每个平台上渲染引擎的细节,而这些细节可能很难修改。我的建议(未经测试,因为缺乏时间和访问 Windows):

  • 安装 cairoDevice 包并使用 Cairo_png()。根据文档:
 此功能与任何其他 R 图形设备相同。您可以
 使用传统的绘图命令并期望基本相同
 输出,除了所有内容都是抗锯齿的(类似于其他
 基于矢量的设备,如 Quartz)。支持 Alpha 混合,如
 通过“getGraphicsEvent”增强了交互性。该设备
 在所有支持的平台(Mac、Windows、
 和 Linux)。
  • 以更高的分辨率渲染 PNG(或将 R 中的数据输出为 PDF),并使用 ImageMagick(convert)或其他工具来获取所需的抗锯齿版本。

This is likely to depend on details of the rendering engine on each platform, which could be hard to modify. My suggestions (untested, for lack of time and access to Windows):

  • install the cairoDevice package and use Cairo_png(). According to the documentation:
 This functions the same as any other R graphics device. You may
 use the conventional plot commands and expect essentially the same
 output, except that everything is anti-aliased (similar to other
 vector-based devices like Quartz). Alpha-blending is supported, as
 is enhanced interactivity via ‘getGraphicsEvent’. The device
 should work the same across all supported platforms (Mac, Windows,
 and Linux).
  • Render the PNG at a much higher resolution (or output data from R as PDF) and use ImageMagick (convert) or some other tool to get the anti-aliased version you need.
一瞬间的火花 2024-11-15 03:31:14

将 Cairo 与 png 设备一起使用时不再需要安装 cairoDevice。现在,您可以在打开设备时指定 type='cairo'。比较以下内容:

png('test1.png', 500, 500)
s3d <- scatterplot3d(wt,disp,mpg, pch=16, highlight.3d=TRUE,
                     type="h", main="3D Scatterplot")
fit <- lm(mpg ~ wt+disp) 
s3d$plane3d(fit)
dev.off()

在此处输入图像描述

png('test2.png', 500, 500, type='cairo')
s3d <- scatterplot3d(wt,disp,mpg, pch=16, highlight.3d=TRUE,
                     type="h", main="3D Scatterplot")
fit <- lm(mpg ~ wt+disp) 
s3d$plane3d(fit)
dev.off()

在此处输入图像描述

我运行的是 Win 8.1 和 64 位 R 3.2.2。

Installing cairoDevice is no longer necessary for using Cairo with png devices. You can now specify type='cairo' when opening the device. Compare the following:

png('test1.png', 500, 500)
s3d <- scatterplot3d(wt,disp,mpg, pch=16, highlight.3d=TRUE,
                     type="h", main="3D Scatterplot")
fit <- lm(mpg ~ wt+disp) 
s3d$plane3d(fit)
dev.off()

enter image description here

png('test2.png', 500, 500, type='cairo')
s3d <- scatterplot3d(wt,disp,mpg, pch=16, highlight.3d=TRUE,
                     type="h", main="3D Scatterplot")
fit <- lm(mpg ~ wt+disp) 
s3d$plane3d(fit)
dev.off()

enter image description here

I'm running Win 8.1, and 64-bit R 3.2.2.

好倦 2024-11-15 03:31:14

使用矢量设备,例如 pdf。首先确保您具有该功能,因此毫不奇怪,要检查的功能是功能。如果您确实有 pdf,那么只需执行以下操作:

pdf(file="out_graph.pdf")
s3d <-scatterplot3d(wt,disp,mpg, pch=16, highlight.3d=TRUE,
  type="h", main="3D Scatterplot")
fit <- lm(mpg ~ wt+disp) 
s3d$plane3d(fit)
dev.off()

Web 输出的替代方案可能是 png() 图形设备。尽管它是一种光栅格式,但它在紧凑性和网络浏览器兼容性方面获得了很高的评价。

Use a vector device such as pdf. First make sure you have that capability and so not surprisingly the capabilities function is what to check. If you do have pdf then just do this:

pdf(file="out_graph.pdf")
s3d <-scatterplot3d(wt,disp,mpg, pch=16, highlight.3d=TRUE,
  type="h", main="3D Scatterplot")
fit <- lm(mpg ~ wt+disp) 
s3d$plane3d(fit)
dev.off()

An alternative for web output might be the png() graphics device. It gets high marks for compactness and web browser compatibility although it is a raster format.

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