[R] Labelling certain points on the x-axis

Jim Lemon jim at bitwrit.com.au
Mon Aug 20 14:19:32 CEST 2007


squall44 wrote:
> Hello,
> 
> I created an empirical distribution function:
> 
> x = c(1.6,1.8,2.4,2.7,2.9,3.3,3.4,3.4,4,5.2)
> F2.5 <- ecdf(x)
> plot(F2.5, 
>      verticals= TRUE, 
>      do.p = TRUE, 
>      lwd=3, 
>      ylab = "f(x)", 
>      xlab = "x", 
>      main = "Figur 2.5 Empirische Verteilfunktion", 
>      xlim = c(1,5.5))
> abline(h= (0:5)*0.2)
> 
> Now I would like to label the points on the x-axis where there is an
> x-value:

Given that you have two labels at the same point, you will have to 
stretch out your labels. I took out the X axis label to get enough room.

library(plotrix)
plot(F2.5,
  verticals= TRUE,
  do.p = TRUE,
  lwd=3,
  ylab = "f(x)",
  xlab = "",
  main = "Figur 2.5 Empirische Verteilfunktion",
  xlim = c(1,5.5))
abline(h= (0:5)*0.2)
staxlab(at=x,labels=paste("X[",1:10,"]",sep=""),nlines=3,top.line=2)

Jim



More information about the R-help mailing list