log-axis not possible anymore (?)

48 views
Skip to first unread message

Marius Hofert

unread,
Apr 21, 2012, 3:02:35 AM4/21/12
to ggplot2
Hi,

under R 2.14, I used ggplot2 to create a plot matrix. I used
scale_x_continuous(trans="log10") to get the axis in log-scale. Now
(four months later; unter R 2.15.0), I ran the same code again and
realized that the axis scale is not correct anymore (the labels are
overplotted as well, one even shows the wrong number but I guess
that's due to some clipping). I then installed ggplot2 with devtools
(see https://gist.github.com/1150934) because I remember that this
once (under R 2.14) solved some of my problems (thanks to Kohske for
the advice). I was hoping this would solve the problem again under
2.15, but it didn't. I am wondering why my former code is not working
anymore.

I checked one of my former minimal examples I posted (see
https://groups.google.com/group/ggplot2/browse_thread/thread/74ded9936428b17e
but also below), and when I ran it, it reproduced the problem. How can
I get the x-axis in log-scale?

In case this minimal example does not reproduce non-log-x-scale for
you, please let me know. I can provide a screen shot.

Cheers,

Marius

Note that I'm working on Mac OS X 10.7.3.

require(ggplot2)
require(reshape2)
require(plyr)

## parameters of some model
p1 <- c(20, 50, 100, 200)
p2 <- c(5, 10, 20, 50, 100)
p3 <- c("group.1","group.2","group.3","group.4","group.5")
p4 <- c(0.2, 0.5, 0.8)
## replications
N <- 1000
## lengths
l1 <- length(p1)
l2 <- length(p2)
l3 <- length(p3)
l4 <- length(p4)
## build result array containing the measurements
arr <- array(rep(NA, l1*l2*l3*l4*N), dim=c(l1, l2, l3, l4, N),
dimnames=list(
p1=p1,
p2=p2,
p3=p3,
p4=p4,
N=1:N))
## fill the result array (dummy here) with values
for(i in 1:l1){
for(j in 1:l2){
for(k in 1:l3){
for(l in 1:l4){
arr[i,j,k,l,] <- i+j+k+l+runif(N)
}
}
}
}

## create molten data
mdf <- melt(arr, formula = . ~ + p1 + p2 + p3 + p4 + N) # create
molten data frame
mdf <- mutate(mdf, p12=p1*p2) # add p1*p2

## build means (dummy function here)
mdf.mean <- dcast(mdf, p1 + p2 + p12 + p3 + p4 ~ "Value",
fun.aggregate=mean, value_var="value")
str(mdf.mean)

## plot
p <- ggplot(mdf.mean, aes(x=p12, y=Value, colour=p1)) +
geom_line(aes(group=p1)) + geom_point() +
facet_grid(p3 ~ p4, scales = "free_y") +
scale_x_continuous(trans="log10")
p

Hadley Wickham

unread,
Apr 21, 2012, 9:49:02 AM4/21/12
to Marius Hofert, ggplot2
It works fine for me in the dev version - make sure you install both
ggplot2 and scales:

install_github(c("ggplot2", "scales"))

Hadley

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

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

Marius Hofert

unread,
Apr 21, 2012, 10:02:37 AM4/21/12
to Hadley Wickham, ggplot2
Dear Hadley,

thanks for helping. 

I remember when I first had the problem under R 2.14, I did this:

require(devtools)
dev_mode(TRUE)
install_github("scales")
install_github("ggplot2", "hadley", "develop")
install_github("ggplot2", "kohske", "feature/new-guides-with-gtable") # hint from Kohske

I also tried just install_github(c("ggplot2", "scales")). Either way, the axis scale is not correct. I attached a screenshot which shows the problem for the minimal example. Hmmm.... 

Cheers,

Marius

Marius Hofert

unread,
Apr 21, 2012, 10:18:41 AM4/21/12
to Hadley Wickham, ggplot2
I just wanted to check back with R 2.14 to see if it was an R 2.15 problem. When installing ggplot2, I obtained:

d> install_github("ggplot2")
Installing github repo(s) ggplot2/master from hadley
Installing ggplot2.zip from https://github.com/hadley/ggplot2/zipball
Installing ggplot2
Loading required package: grDevices
* checking for file ‘/private/var/folders/5r/fpc7qzk55ll71t9j8l9d1d_00000gn/T/RtmpVMtCGl/hadley-ggplot2-c75fb70/DESCRIPTION’ ... OK
* preparing ‘ggplot2’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* looking to see if a ‘data/datalist’ file should be added
* building ‘ggplot2_0.9.0.tar.gz’

Loading required package: grDevices
* installing *source* package ‘ggplot2’ ...
** R
** data
** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Error in library.dynam(lib, package, package.lib) :
shared object ‘digest.so’ not found
ERROR: lazy loading failed for package ‘ggplot2’
* removing ‘/Users/mhofert/R-dev/ggplot2’
* restoring previous ‘/Users/mhofert/R-dev/ggplot2’
Error: Command failed (1)

In comparison to https://gist.github.com/1150934 I also had to install digest and MASS. But then I could install ggplot2 under R 2.14. The problem is, when I call it, I obtain:

R version 2.14.0 (2011-10-31)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-apple-darwin11.2.0/x86_64 (64-bit)
...
Loading required package: grDevices
> > assignInNamespace(".help.ESS",help, ns = asNamespace("base"))
> options(STERM='iESS', str.dendrogram.last ="'", editor='emacsclient')
> Loading required package: ggplot2
Warning message:
package ‘ggplot2’ was built under R version 2.15.0
> Loading required package: reshape2
Warning message:
package ‘reshape2’ was built under R version 2.15.0
> Loading required package: plyr
> > > > > > > > > > > > > > > + + + + + + > > + + + + + + + + > > > > Error: unexpected symbol in "molten data"




On 2012-04-21, at 15:49 , Hadley Wickham wrote:

Marius Hofert

unread,
Apr 22, 2012, 3:46:53 PM4/22/12
to Hadley Wickham, ggplot2
In the meantime I managed to install (scales and) ggplot2 in the development version on Ubuntu 12.04. I obtain the same result (so no Mac problem) I wonder what changed in the development version that my code does not run anymore, I didn't change the code.

Marius Hofert

unread,
Apr 22, 2012, 5:10:29 PM4/22/12
to Hadley Wickham, ggplot2
Okay, I found the problem. I had "scales" (the non-devel version) still in .libPaths and so this was found instead of the one in ~/R-dev.

Cheers,

Marius
Reply all
Reply to author
Forward
0 new messages