Is their any process to improve jagged lines produced by geom_line() joining multiple points into smooth presentable lines in ggplot2?
lai.se <- structu
As others have mentioned, a vector-based image format like PDF or SVG might be the best way to go. If you want to use a bitmap, like PNG, then you can increase the resolution of your image with the res
option of png()
.
png("myplot.png", width = 1800, height = 1800, res = 600)
This will produce a 3 inch by 3 inch image (in real-world dimensions) at 600 dpi. In my experience, the file size was still reasonable for relatively simple graphs.
See this blog post for more ideas on how to improve your images:
http://blog.revolutionanalytics.com/2009/01/10-tips-for-making-your-r-graphics-look-their-best.html
Output your graph to a file stored in a vector format, such as PDF or PostScript, and then use ImageMagick or similar to render that vector image to a bitmap (PNG, JPEG, etc.) at high resolution (150, 300 or even 600 dpi):
$ convert myGraphAsVector.pdf -density 300 myGraphAs300DpiBitmap.png
The file size will be large (and get increasingly larger as you increase the resolution of the final product), but the jaggedness of the bitmap will appear to go away at higher pixel densities.
In your answer to my comment you confirm that you want to anti-alias your lines (not change the curve of your plot).
I think the only way to do that in R is to use Cairo and here is a tutorial on how to do that with circles, i hope you can adapt that to do it with lines:
http://www.r-bloggers.com/weekend-art-in-r-part-3/
I'm guessing you're trying to smooth a line. Is this in the ball park of what you're after?
ggplot(lai.se, aes(x=DAS, y=LAI, colour=DOS)) +
geom_errorbar(aes(ymin=LAI-se, ymax=LAI+se), colour ="black", size =.5, width=1, position=position_dodge(.9)) +
geom_smooth() +
geom_point()+ theme_bw()