Ian No differences with Adobe X with the following
windows(6,6) #pdf(file = "TestPlot.pdf", 6, 6) #{ plot(b, l, type = "l", ylim = c(y.min, y.max), lwd = 2, xlab = expression(beta), ylab = "", col = "green", yaxt = "n", xaxt = "n") points(b, p, type = "l", lty = "dotted", lwd = 2, col = "red") points(b, pen.like, type = "l", lwd = 2, lty = "dashed", col = "green") axis(1, at = c(0)) axis(2, at = c(0)) lambda.hat = which.max(pen.like) lambda.glm = which(b == b.hat) points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5) points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5) b.hat = -3 a.1 = -1.5 a.2 = 0 a.3 = 120 l = a.1*(b - b.hat)^2 + a.2*(b - b.hat) + a.3 pen.like = l + p points(b, l, type = "l", lwd = 2, col = "blue") points(b, pen.like, type = "l", lwd = 2, lty = "dashed", col = "blue") lambda.hat = which.max(pen.like) lambda.glm = which(b == b.hat) points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5) points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5) abline(h = 0) abline(v = 0) #} #dev.off() dev.copy2pdf(file = "TestPlot_devcopy2pdf.pdf") as well as the pdf() and manual Save As sessionInfo() R version 2.15.2 (2012-10-26) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252 LC_NUMERIC=C LC_TIME=English_Australia.1252 attached base packages: [1] datasets utils stats graphics grDevices grid methods base other attached packages: [1] lhs_0.10 R.oo_1.10.1 R.methodsS3_1.4.2 foreign_0.8-51 chron_2.3-43 MASS_7.3-22 latticeExtra_0.6-24 RColorBrewer_1.0-5 [9] lattice_0.20-10 loaded via a namespace (and not attached): [1] tools_2.15.2 Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au At 10:09 20/02/2013, you wrote: >Hi, I am trying to save a plot as a PDF with different line types. >In the example below, R displays the plot correctly with 2 curves in >solid lines, 2 curves in dashed lines and 1 curve as a dotted line. >However, when I save the image as PDF (as attached), the dashed >lines become solid. >This also happens if I use the pdf command directly (by removing the ># symbols). Is there any way around this? > Saving the image as a JPEG or PNG file works fine but the image > quality is not desirable. > >b.hat = 6 >a.1 = -12 >a.2 = 0 >a.3 = 200 >b = seq(-10, 10, 0.0002) >l = a.1*(b - b.hat)^2 + a.2*(b - b.hat) + a.3 >lambda = 20 >p = -lambda*abs(b) >pen.like = l + p >y.min = 3*min(p) >y.max = max(c(l, p, pen.like)) > >#pdf(file = "TestPlot.pdf", 6, 6) >#{ >plot(b, l, type = "l", ylim = c(y.min, y.max), lwd = 2, xlab = >expression(beta), ylab = "", col = "green", yaxt = "n", xaxt = "n") >points(b, p, type = "l", lty = "dotted", lwd = 2, col = "red") >points(b, pen.like, type = "l", lwd = 2, lty = "dashed", col = "green") >axis(1, at = c(0)) >axis(2, at = c(0)) >lambda.hat = which.max(pen.like) >lambda.glm = which(b == b.hat) >points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5) >points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5) >b.hat = -3 >a.1 = -1.5 >a.2 = 0 >a.3 = 120 >l = a.1*(b - b.hat)^2 + a.2*(b - b.hat) + a.3 >pen.like = l + p >points(b, l, type = "l", lwd = 2, col = "blue") >points(b, pen.like, type = "l", lwd = 2, lty = "dashed", col = "blue") >lambda.hat = which.max(pen.like) >lambda.glm = which(b == b.hat) >points(b[lambda.glm], l[lambda.glm], pch = 16, cex = 1.5) >points(b[lambda.hat], l[lambda.hat], pch = 17, cex = 1.5) >abline(h = 0) >abline(v = 0) >#} >#dev.off() > >Thanks, Ian > ><file://g:\eudora\attach\TestPlot.pdf><file://g:\eudora\attach\TestPlot.pdf> >TestPlot.pdf >______________________________________________ >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]] ______________________________________________ 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.