[R] Problems with line types in plots saved as PDF files
David Winsemius
dwinsemius at comcast.net
Wed Feb 20 05:22:13 CET 2013
On Feb 19, 2013, at 7:40 PM, Ista Zahn wrote:
> On Tue, Feb 19, 2013 at 10:20 PM, Ian Renner <ian_renner at yahoo.com> wrote:
>> Hi Ista,
>>
>> I'm using Adobe Reader XI. It's good to hear that the plot was produced
>> correctly and that it is Adobe that is failing to represent it properly.
>
> Right, well I just installed acroread (adobe reader for linux) and I
> do see the problem you originally described. So all is not well,
> unless you convince people not to use Adobe reader to view the
> document. Sorry I can't be of more help at the moment, as I'm headed
> to bed. If no one else beats me to it I'll take another look in the
> morning.
Just for the record the Apple pdf viewer, Preview.app, displays it as described: two solid lines, two dashed lines and one dotted line.
--
David.
>
> Best,
> Ista
>
>> Thanks!
>>
>> Ian
>>
>> ________________________________
>> From: Ista Zahn <istazahn at gmail.com>
>> To: Ian Renner <ian_renner at yahoo.com>
>> Cc: "r-help at r-project.org" <r-help at r-project.org>
>> Sent: Wednesday, 20 February 2013 2:14 PM
>> Subject: Re: [R] Problems with line types in plots saved as PDF files
>>
>> Hi,
>>
>> On Tue, Feb 19, 2013 at 7:09 PM, Ian Renner <ian_renner at yahoo.com> 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.
>>
>> I see two solid lines, two dashed lines, and one dotted, using okular
>> version 0.16.0. I suspect your pdf viewer is buggy. What are you using
>> to view the pdf?
>>
>> Best,
>> Ista
>>
>> 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
>>>
>>> ______________________________________________
>>> R-help at 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.
>>>
>>
>>
>
> ______________________________________________
> R-help at 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.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list