zoom to a region of the plot after log transformation

21 views
Skip to first unread message

Dani Linares

unread,
May 22, 2009, 9:26:18 AM5/22/09
to ggplot2
Hi,
that works:

library("ggplot2")
df<-data.frame(x=c(1,2,3),y=c(10,100,500))
p<-ggplot(data=df,aes(x=x,y=y))+geom_line()
#p<-p+scale_y_log10()
p<-p+coord_cartesian(ylim = c(20,30))
p

but this doesnt work:

library("ggplot2")
df<-data.frame(x=c(1,2,3),y=c(10,100,500))
p<-ggplot(data=df,aes(x=x,y=y))+geom_line()
#p<-p+scale_y_log10()
p<-p+coord_cartesian(ylim = c(20,30))
p


dani


--
Daniel Linares
web: www.dlinares.org

Dani Linares

unread,
May 22, 2009, 9:30:21 AM5/22/09
to ggplot2
sorry, the second piece of code should not have #

definitely, today is not my 'copy and paste' day

dani,

hadley wickham

unread,
Jun 4, 2009, 5:37:49 PM6/4/09
to Dani Linares, ggplot2
Currently, you'll need to manually transform the coord_cartesian limits:

df<-data.frame(x=c(1,2,3),y=c(10,100,500))
p<-ggplot(data=df,aes(x=x,y=y))+geom_line()
p<-p+scale_y_log10()
p<-p+coord_cartesian(ylim = log10(c(20,30)))
p


Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages