3

Possible Duplicate:
can I separately control the x and y axes using ggplot?

I saw an earlier post describing how to do this (can I separately control the x and y axes using ggplot?)-but it doesn´t work in ggplot 0.9.0. Any ideas how I can remove only the y-axis line, and not the x axis line. The axis.line option does not allow any differenatiation between the two axes.

 u<-expand.grid(temp=seq(0,100,10),hum=c(20,90),delta=as.factor(seq(0,10,by=5)))

u$model<-exp(u$temp*log(0.88)+u$hum*log(1.01)+as.numeric(u$delta)*log(1.1)) 
u2<-subset(u,hum==20)

u4<-subset(u,hum==90)
pl<-ggplot()+
  geom_line(data=u2,aes(x=u2$temp,y=u2$model,colour=u2$delta,group=u2$delta))+
  geom_line(data=u4,aes(x=temp,y=model,colour=delta,group=delta))

pl+theme_bw()+
  opts(panel.grid.minor=theme_blank(),
       panel.grid.major=theme_blank(),
       legend.key=theme_blank(),
       panel.border=theme_rect(colour=NA),
       axis.line=theme_segment(colour='grey',size=1))

Now - how can I just have the x-axis and not the y-axis line?

The earlier post recommended

grid.remove(gPath("axis_v", "axis.line.segments"), grep=TRUE)

resulting in

Error in removeDLFromGPath(gPath, name, strict, greppath, grepname, global, : gPath (axis_v::axis.line.segments) not found

//M

Community
  • 1
  • 1
Misha
  • 3,114
  • 8
  • 39
  • 60

1 Answers1

2

Here is a work-around that may help. Set the plotting limits strictly with coord_cartesian() and then add x-axis line manually. It shouldn't be too hard to calculate the y-axis range programmatically.

opts(axis.line=theme_blank()) +
coord_cartesian(ylim=c(-0.05, 3.3)) + 
geom_hline(yintercept=-0.05, colour="grey", size=1.5)
bdemarest
  • 14,397
  • 3
  • 53
  • 56