Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anti-aliasing in R graphics under Windows (as per Mac)

Tags:

r

antialiasing

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.

like image 960
Thomas Browne Avatar asked May 16 '11 20:05

Thomas Browne


People also ask

Is anti-aliasing good for graphics?

Anti-aliasing is a way for your computer to play nice with all those pixels in PC games and smooth them out into graphics worthy of this century. In short, it's a graphics setting that helps get rid of jaggies. If you're running a game on a higher resolution, you're in luck.

What is anti-aliasing computer graphics?

Anti-aliasing is a method by which you can eliminate jaggies that appear in objects in PC games. There are several different types of anti-aliasing methods, each with its own pros and cons. Most PC games have an in-game window where you're able to adjust graphics settings, including anti-aliasing.

Where is the anti-aliasing?

Aliasing is the visual stair-stepping of edges that occurs in an image when the resolution is too low. Anti-aliasing is the smoothing of jagged edges in digital images by averaging the colors of the pixels at a boundary. The letter on the left is aliased.


1 Answers

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.
like image 136
Ben Bolker Avatar answered Oct 14 '22 21:10

Ben Bolker