[R] scatterplot of 100000 points and pdf file format
Marc Schwartz
MSchwartz at MedAnalytics.com
Wed Nov 24 18:46:56 CET 2004
On Wed, 2004-11-24 at 17:43 +0100, Witold Eryk Wolski wrote:
> Hi,
>
> I tried the ps idea. But I am using pdflatex.
> You get a even larger size reduction if you convert the ps into a pdf
> using ps2pdf.
> But unfortunately there is a quality loss.
>
> I have found almost a working solution:
> a) Save the scatterplot without axes and with par(mar=c(0,0,0,0)) as png .
> b) convert it using any program to pnm
> c) read the pnm file using pixmap
> d) Add axes labels and lines afterwards with par(new=TRUE)
>
> And this looks like I would like that it looks like. But unfortunately
> acroread and gv on window is crashing when I try to print the file.
>
> png(file="pepslop.png",width=500,height=500)
> par(mar=c(0,0,0,0))
> X2<-rnorm(100000)
> Y2<-X2*10+rnorm(100000)
> plot(X2,Y2,pch=".",xlab="",ylab="",main="",axes=F)
> dev.off()
>
> pdf(file="pepslop.pdf",width=7,height=7)
> par(mar=c(3.2,3.2,1,1))
> x <- read.pnm("pepslop.pnm" )
> plot(x)
> par(new=TRUE)
> par(mar=c(3.2,3.2,1,1))
> plot(X2,Y2,pch=".",xlab="",ylab="",main="",type="n")
> mtext(expression(m[nominal]),side=1,line=2)
> mtext(expression(mod(m[monoisotopic],1)),side=2,line=2)
> legend(1000,4,expression(paste(lambda[DB],"=",0.000495)),col=2,lty=1,lwd=1)
> abline(test,col=2,lwd=2)
> dev.off()
Eryk,
I tried this approach and was able to print without problem here under
FC3, using acroread.
Also, I think that you left out:
test <- lm(Y2 ~ X2)
in the code above, lest abline() will fail. Also I changed the x,y
coordinates of the legend, since (1000, 4) is outside the plot range for
the points that I generated here.
Interesting approach, it reduced the pdf file size to about 7 Mb.
BTW, any chance that there is a huge black hole in the center of
that... ;-)
Best,
Marc
More information about the R-help
mailing list