The Cairo-package
The Cario package is an excellent choice for getting antia-aliased plots in Windows. Here’s the same plot from the Cairo package (the background is now transparent):
1 2 3 4 5 6 7 8 9 10 | library(Cairo) Cairo(file="Cairo_PNG_72_dpi. |
If we want to increase the resolution of the plot we can’t just change the resolution parameter:
We also have to change the point size, the formula is size * new resolution DPI / 72 DPI:
Adjusted point size results in the labels remaining the proper sizeIf we double the image size we also need to double the point size:
If you want the background to be white just add the bg parameter:
Here’s the plot code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Create the data data <- rnorm(100, sd=15)+1:100 # Create a simple scatterplot # with long labels to enhance # size comparison my_sc_plot <- function(data){ par(cex.lab=1.5, cex.main=2) plot(data, main="A simple scatterplot", xlab="A random variable plotted", ylab="Some rnorm value", col="steelblue") x <- 1:100 abline(lm(data~x), lwd=2) } |