R 中的 qplot 和抗锯齿

发布于 2024-08-15 03:20:11 字数 179 浏览 2 评论 0原文

我正在使用 ggplot2 库并使用 qplot 命令 我知道我可以在 qplot 之后使用以下命令将输出保存为抗锯齿图像文件,

ggsave(file="filename.png")

但是我的 LCD 显示器怎么样?有什么方法可以在监视器上看到抗锯齿 grpah 的绘图吗?

I am using ggplot2 library and am working with the qplot command
I know I can save my output as an anti-aliased image file by using the following command after my qplot

ggsave(file="filename.png")

But how about my LCD display? is there any way to see a plot on the monitor as anti-aliased grpah?

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

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

发布评论

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

评论(4

木格 2024-08-22 03:20:11

正如其他人提到的,R 的内置 Windows 图形设备不执行抗锯齿功能。但现在安装 Cairo 图形设备很容易。

在 R 控制台:

install.packages('Cairo',,'http://www.rforge.net/')

要测试:

plot(rnorm(1000)) # non-antialiased (on Windows)
library('Cairo')
CairoWin()
plot(rnorm(1000)) # antialiased!

更多

As others have mentioned, R's built-in Windows graphics device does not do anti-aliasing. But nowadays it's easy to install the Cairo graphics device which does.

At the R console:

install.packages('Cairo',,'http://www.rforge.net/')

To test:

plot(rnorm(1000)) # non-antialiased (on Windows)
library('Cairo')
CairoWin()
plot(rnorm(1000)) # antialiased!

More

狂之美人 2024-08-22 03:20:11

在 Windows 上,没有内置的抗锯齿功能。我不知道未来版本是否有计划。您可以从 cairoDeviceCairo 包中获取基于 Cairo 的图形设备;但是,您需要先安装 GTK+

http://gladewin32.sourceforge.net/

另一种选择是通过 JGR 使用基于 Java 的图形 (http://jgr .markushelbig.org/)。我认为基于 Qt 的设备也正在开发中。

On Windows, there is no built-in anti-aliasing. I don't know whether it is planned for future releases or not. You can get a Cairo-based graphics device from either the cairoDevice or Cairo packages; however, you will need to install GTK+ first:

Download and install Gtk+ 2.12.9 Runtime Environment Revision 2 from http://gladewin32.sourceforge.net/

Another option would be to use Java-based graphics through JGR (http://jgr.markushelbig.org/). Also a Qt-based device is under development, I think.

浅唱々樱花落 2024-08-22 03:20:11

如果您安装了 Cairo(请参阅其他答案),要将其另存为抗锯齿 PNG,只需将代码更改为:

ggsave(file="filename.png", type="cairo-png")< /code>

此处指定。

但是出于什么目的,您想要“在监视器上看到图形作为抗锯齿图形”或“对我的绘图窗口进行抗锯齿”?如果您的意思是像 RStudio 中的绘图窗口(选项卡)一样,我不确定是否可以做到,它基本上只是作为预览。我建议您将图表保存到文件中,然后使用该文件来显示它或用于任何其他目的。

If you have Cairo installed (see the other answers), to save it as an anti-aliased PNG, just change your code to:

ggsave(file="filename.png", type="cairo-png")

as specified here.

But for what purpose do you want to "see a plot on the monitor as anti-aliased graph" or "anti-alias my plot windows"? If you mean like in the Plots window (tab) in RStudio, I am not sure that can be done, it serves basically just as a preview. I suggest you save the graph to a file and then use this file to display it or for any other purpose.

最笨的告白 2024-08-22 03:20:11

好的,我刚刚检查过。我之前的评论是错误的。从 help(x11) 中可以获得很多详细信息 - 基于开罗的新设备确实具有抗锯齿功能:

x11 封装:grDevices
R 文档

X 窗口系统图形

描述:

 'X11' 启动 X Window 系统的图形设备驱动程序
 (版本 11)。这只能在机器/帐户上完成
 可以访问 X 服务器。

 “x11”被识别为“X11”的同义词。

用法:

 X11(显示 = "", 宽度, 高度, 点数, gamma, bg, 画布,
     字体、xpos、ypos、标题、类型、抗锯齿)

 X11.options(..., 重置 = FALSE)

参数:

[...]

 字体:X11 字体描述字符串,其中包含粗细、倾斜和
      尺寸将被替换。有两个,第一个是字体
      1到4,第二个为字体5,符号字体。看
      “字体”部分。 

[...]

 antialias:对于 cairo 类型,抗锯齿类型(如果有)为
      用过的。 'c("默认"、"无"、"灰色"、"子像素")'之一。 

[...]

详细信息:

 'X11' 的所有参数的默认值由
 “X11.options”:“参数”部分提供“工厂新鲜”
 默认值。

 初始大小和位置仅是提示,可能无法执行
 由窗口管理器打开。此外,某些系统(尤其是笔记本电脑)
 被设置为看起来有一个不同尺寸的屏幕
 物理屏幕。

 选项“type”在两个单独的设备之间进行选择:可以构建 R
 不支持“type =“Xlib””或两者都支持。两者都在哪里
 可用,类型“cairo”和“nbcairo”报价

    * 文本和线条的抗锯齿。

    * 半透明的颜色。

    * 可缩放文本,包括 4.5 pt 等尺寸。

    * 全面支持UTF-8,这样系统上就有适合你的字体
      可以用多种语言在单个图形上绘制(这将
      即使在非 UTF-8 语言环境中也能工作)。输出应该是
      独立于语言环境。

 'type = "nbcairo"' 与 'type="cairo"' 是同一设备,但不带
 缓冲:哪个更快取决于 X11 连接。
 两者都会比 'type = "Xlib"' 慢,尤其是在慢速 X11 上
 连接,因为所有渲染都在运行 R 的机器上完成
 而不是在 X 服务器中。

 所有使用 X11 服务器的设备(包括 'type = "Xlib"'
 位图设备的版本(例如“png”)共享内部
 结构,这意味着它们必须使用相同的“显示”和
 视觉的。如果要更改显示,请先关闭所有此类
 设备。 

[...以及更多...]

Ok, I just checked. I was wrong in my earlier comment. From help(x11) where a lot of detail is available -- the new Cairo-based devices do have anti-aliasing available:

x11 package:grDevices
R Documentation

X Window System Graphics

Description:

 ‘X11’ starts a graphics device driver for the X Window System
 (version 11).  This can only be done on machines/accounts that
 have access to an X server.

 ‘x11’ is recognized as a synonym for ‘X11’.

Usage:

 X11(display = "", width, height, pointsize, gamma, bg, canvas,
     fonts, xpos, ypos, title, type, antialias)

 X11.options(..., reset = FALSE)

Arguments:

[...]

 fonts: X11 font description strings into which weight, slant and
      size will be substituted.  There are two, the first for fonts
      1 to 4 and the second for font 5, the symbol font.  See
      section ‘Fonts’. 

[...]

 antialias: for cairo types, the typeof anti-aliasing (if any) to be
      used.  One of ‘c("default", "none", "gray", "subpixel")’. 

[...]

Details:

 The defaults for all of the arguments of ‘X11’ are set by
 ‘X11.options’: the ‘Arguments’ section gives the ‘factory-fresh’
 defaults.

 The initial size and position are only hints, and may not be acted
 on by the window manager.  Also, some systems (especially laptops)
 are set up to appear to have a screen of a different size to the
 physical screen.

 Option ‘type’ selects between two separate devices: R can be built
 with support for neither, ‘type = "Xlib"’ or both.  Where both are
 available, types ‘"cairo"’ and ‘"nbcairo"’ offer

    * antialiasing of text and lines.

    * translucent colours.

    * scalable text, including to sizes like 4.5 pt.

    * full support for UTF-8, so on systems with suitable fonts you
      can plot in many languages on a single figure (and this will
      work even in non-UTF-8 locales).  The output should be
      locale-independent.

 ‘type = "nbcairo"’ is the same device as ‘type="cairo"’ without
 buffering: which is faster will depend on the X11 connection.
 Both will be slower than ‘type = "Xlib"’, especially on a slow X11
 connection as all the rendering is done on the machine running R
 rather than in the X server.

 All devices which use an X11 server (including the ‘type = "Xlib"’
 versions of bitmap devices such as ‘png’) share internal
 structures, which means that they must use the same ‘display’ and
 visual.  If you want to change display, first close all such
 devices. 

[...and more...]

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