axis.line not showing on the y-axis

1,430 views
Skip to first unread message

Luke

unread,
Feb 18, 2010, 5:16:29 PM2/18/10
to ggplot2
I am a new ggplot2 user working through the Wickham book. I am trying
to get my first plot completed using my own data and am attempting to
add solid lines to the axes. Each time I try, however, the line for
the y-axis does not appear. I have taken the plot down to its simplest
form and have tried using different data with no success. I tried
using both methods below and the y-axis is missing in both

P1 <- ggplot(xy.data, aes(x, y))
P1 <- P1 + layer(geom = "point")
P1 + opts(axis.line = theme_segment())

Initially I had the opts added to the first line with the same results
I also tried

qplot(x, y) + opts(axis.line = theme_segment())


The x-axis line shows up perfectly in both cases

Thanks for any help

smu

unread,
Feb 18, 2010, 6:55:11 PM2/18/10
to Luke, ggplot2
Hello Luke,

I can't reproduce it, in the following example, both axes are visible:

x=1:10
xy.data=data.frame(x=x,y=y)


P1 <- ggplot(xy.data, aes(x, y))
P1 <- P1 + layer(geom = "point")
P1 + opts(axis.line = theme_segment())

not the same for you?

regards,
stefan

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
>

Luke

unread,
Feb 19, 2010, 11:31:40 AM2/19/10
to ggplot2
Thanks Stefan,

I ran your script (adding in y=1:10) with the same results, no y-axis
line. I have reinstalled R + ggplot2 with no success. I have also
tried saving the plot in case it was simply a graphics display error.
Since it is working for you I can only assume it is my machine that is
causing the trouble. I'll try my home comp tonight and let you know
the results.

- Luke

Luke

unread,
Feb 19, 2010, 8:16:42 PM2/19/10
to ggplot2

I ran the test script above on my home computer and the same problem
occured. This is also with a fresh install of R and ggplot2 off of the
Berkley mirror.

Jonathan Christensen

unread,
Feb 19, 2010, 8:50:29 PM2/19/10
to Luke, ggplot2
I can confirm the bug (running R 2.10.1 and ggplot2 0.8.6 on Windows 7). It looks like the y-axis is being drawn underneath the plot background. On screen it doesn't show up at all; in a pdf (zoomed way in) you can see it peeking through. I've attached a sample, if it gets through.

FWIW, the same behavior is visible in the PDFs of the ggplot2 book (from SpringerLink), fig. 8.3 (p. 145).

Jonathan



bug.png

hadley wickham

unread,
Feb 24, 2010, 11:20:17 AM2/24/10
to Jonathan Christensen, Luke, ggplot2
> I can confirm the bug (running R 2.10.1 and ggplot2 0.8.6 on Windows 7). It
> looks like the y-axis is being drawn underneath the plot background. On
> screen it doesn't show up at all; in a pdf (zoomed way in) you can see it
> peeking through. I've attached a sample, if it gets through.

Yes, this is exactly what happens. Unfortunately it's not trivial to
change this, because axis and panels are drawn in completely different
steps. It's added to the bug list -
http://github.com/hadley/ggplot2/issues/issue/78

Hadley

>
> FWIW, the same behavior is visible in the PDFs of the ggplot2 book (from
> SpringerLink), fig. 8.3 (p. 145).
>
> Jonathan
>
>
>
> On Fri, Feb 19, 2010 at 6:16 PM, Luke <justar...@yahoo.com> wrote:
>>
>> I ran the test script above on my home computer and the same problem
>> occured. This is also with a fresh install of R and ggplot2 off of the
>> Berkley mirror.
>>
>> --
>> You received this message because you are subscribed to the ggplot2
>> mailing list.
>> To post to this group, send email to ggp...@googlegroups.com
>> To unsubscribe from this group, send email to
>> ggplot2+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/ggplot2
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages