Trouble with Axis Ticks

120 views
Skip to first unread message

Lorenzo Isella

unread,
Jun 25, 2012, 8:31:49 AM6/25/12
to ggplot2
Dear All,
Please find an easy snippet at the end of the email.
I am reusing some old code of mine and I noticed that now (on a fresh
ggplot2 installation from the R repositories on a box running Debian
mint), I am experiencing troubles.
When I run my snippet, I get this error message

source('test_ggplot2.R')
Error in structure(list(...), class = "options") :
could not find function "unit"

The problem is given by the line

axis.ticks.length = unit(0.15, "cm")

inside ops(...). However, in the past on another machine, I have never got
any error message for this.
Is my new ggplot2 installation buggy or has anything changed recently in
its syntax?
In that case, what is the correct syntax now?
Many thanks for your help.
Cheers

Lorenzo


#################################################################

library(ggplot2)

mydata <- as.data.frame(cbind(seq(10), seq(10)))


names(mydata) <- c("ratio", "N")

b <- ggplot(mydata, aes(x=N, y=ratio)) +

geom_point(size=2) +

opts( panel.background=theme_rect(fill='white',
size=1.5))+
opts(panel.grid.minor = theme_blank())+
opts(panel.grid.major = theme_blank())+
opts(axis.ticks = theme_segment(colour = "black", size=1)
, axis.ticks.length = unit(0.15, "cm")
)

pdf("test.pdf",width=5,height=5)

print(b)
dev.off()

Brandon Hurr

unread,
Jun 25, 2012, 8:40:05 AM6/25/12
to Lorenzo Isella, ggplot2, ggplot2-dev
Add, library(grid)

unit() is part of that package. I'm surprised by this. I know ggplot2 has stripped things away, but I didn't realize that it was quite this stripped down. 

Dennis Murphy

unread,
Jun 25, 2012, 10:36:43 AM6/25/12
to Brandon Hurr, Lorenzo Isella, ggplot2, ggplot2-dev
I believe this has to do with ggplot2 not autoloading packages at
startup as of 0.9.0. Just as you now have to explicitly load plyr and
reshape if you want to use them in a session, so too do you have to
load grid. Every once in a while you forget and get nipped...

Dennis
Reply all
Reply to author
Forward
0 new messages