Brian S Cade
2007-Nov-16 20:28 UTC
[R] graphics - line resolution/pixelation going from R to windows metafile
I have a recurring graphics issue that I've not been able to resolve with R. If I make a series of regression estimates and then plot the estimated function for the regression lines over a scatter plot of the data, e.g., using a sequence of plot( ) and lines ( ) similar to those below plot(dep12spp13ph1$DAYSWETm2,dep12spp13ph1$AFTERDECOMP,pch=dep12spp13ph1$spp,cex=0.75,ylab="Proportion of biomass after leaching", xlab="Number of days in wetland",xlim=c(0,250),ylim=c(0,1)) xplot<- 0:243 xplotbsk64deg1<-bs(xplot,knot=62,degree=1,Boundary.knots=c(0,243)) lines(xplot,exp(xplotbsk64deg1 %*% ph1.decomp.75.bs$coef[c(1,2)]),col="blue") lines(xplot,exp(xplotbsk64deg1 %*% ph1.decomp.75.bs$coef[c(3,4)]),col="red") and then attempt to copy the resulting graph from R graph window into a Windows metafile to paste into another application like Power Point or Word, the resulting regression lines have alot of jagged edges due to resolution/pixelation issues. For a nonlinear function like the one plotted above, changing the number of pairs of points evaluated with the lines( ) function makes the plot look better or worse but never as good as is possible if there was some sort of "smoothing" done on the plotted line pixels. I do this type of graphing in SYSTAT all the time and it looks great (but I would prefer not to have to jump back and forth between R and SYSTAT ). If I save the graph (or print) from R into an encapsulated Post-Script file, then the resulting regression line pixels are "smoothed" out and look nice, but then the symbols have been decomposed into their constituent elements and are screwed up. I'm guessing somewhere in R's graphing parameters/controls there might be a solution but I've yet to find it. Any suggestions would be welcome. Brian Brian S. Cade U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave., Bldg. C Fort Collins, CO 80526-8818 email: brian_cade@usgs.gov tel: 970 226-9326 [[alternative HTML version deleted]]
Mose Andre
2007-Nov-16 23:42 UTC
[R] graphics - line resolution/pixelation going from R to windows metafile
You might try using the Cairo package, which will allow you to bypass using the Windows graphics device and can give you anti-aliasing. As the manual says: "It is ideal for use in server environments (file output) and as a replacement for other devices that don't have Cairo's capabilities such as alpha support or anti-aliasing." http://www.rforge.net/Cairo/ http://cran.r-project.org/src/contrib/Descriptions/Cairo.html - Mose On Nov 16, 2007 12:28 PM, Brian S Cade <cadeb@usgs.gov> wrote:> I have a recurring graphics issue that I've not been able to resolve with > R. If I make a series of regression estimates and then plot the estimated > function for the regression lines over a scatter plot of the data, e.g., > using a sequence of plot( ) and lines ( ) similar to those below > > > plot(dep12spp13ph1$DAYSWETm2,dep12spp13ph1$AFTERDECOMP,pch=dep12spp13ph1$spp,cex> 0.75,ylab="Proportion > of biomass after leaching", xlab="Number of days in > wetland",xlim=c(0,250),ylim=c(0,1)) > xplot<- 0:243 > xplotbsk64deg1<-bs(xplot,knot=62,degree=1,Boundary.knots=c(0,243)) > lines(xplot,exp(xplotbsk64deg1 %*% > ph1.decomp.75.bs$coef[c(1,2)]),col="blue") > lines(xplot,exp(xplotbsk64deg1 %*% > ph1.decomp.75.bs$coef[c(3,4)]),col="red") > > and then attempt to copy the resulting graph from R graph window into a > Windows metafile to paste into another application like Power Point or > Word, the resulting regression lines have alot of jagged edges due to > resolution/pixelation issues. For a nonlinear function like the one > plotted above, changing the number of pairs of points evaluated with the > lines( ) function makes the plot look better or worse but never as good as > is possible if there was some sort of "smoothing" done on the plotted line > pixels. I do this type of graphing in SYSTAT all the time and it looks > great (but I would prefer not to have to jump back and forth between R and > SYSTAT ). If I save the graph (or print) from R into an encapsulated > Post-Script file, then the resulting regression line pixels are "smoothed" > > out and look nice, but then the symbols have been decomposed into their > constituent elements and are screwed up. I'm guessing somewhere in R's > graphing parameters/controls there might be a solution but I've yet to > find it. Any suggestions would be welcome. > > Brian > > Brian S. Cade > > U. S. Geological Survey > Fort Collins Science Center > 2150 Centre Ave., Bldg. C > Fort Collins, CO 80526-8818 > > email: brian_cade@usgs.gov > tel: 970 226-9326 > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]