[R] labelling points plotted in a 2D plan
Petr PIKAL
petr.pikal at precheza.cz
Mon Jul 27 11:47:29 CEST 2009
Hi
r-help-bounces at r-project.org napsal dne 25.07.2009 23:15:04:
> Thanks for the answer Tal!
> But I can't get it to work correctly! :(
> Please bear with me this is the first time I am using R! and I am in a
rush
> to correct a paper
> in fact on the plane I am plotting a table
> > fullpointed=read.table("fullpoints_backup.txt",h=F)
> > plot(range(-2.5,0.95),range(0.00,1.00),type="n",axes=TRUE)
Most probably you do not want axes labeled with "range(-2.5,.95)". Look at
xlab and ylab parameters and also to xlim and ylim parameters
plot(0, 0, xlim=range(-2.5,0.95),ylim=range(0.00,1.00), xlab="bla",
ylab="blabla",type="n",axes=TRUE)
> and in this table there are 300 points
> I want to label the first 175 points with A and the others with S
> I couldn't figure how to configure correctly labels.to.plot <-
> sample(c("A","B"), 100, replace = T) and text(x, y , labels =
> labels.to.plot) ?
>
> for instance:
> 0,48875 0,142857143 > the point plotted will be labelled a
> 0,409 0,142857143 > the point plotted will be labelled a
> 0,45611 0,25 > labelled a
> 0,49833 0,222222222 > labelled a
It is hard to tell what type of data you really have. Output from
str(fullpointed)
could help.
In case you have numeric values
text(fullpointed[,1], fullpointed[,2], labels=c(rep("A", 175),
rep("S",125)))
(untested) could do what you want. But maybe I am completely wrong because
I do not know what "first 175 points" means.
Regards
Pter
> #the first 175
>
> 0,61158 0,125 > labelled S
> 0,5709 0,125 > labelled S
> 0,53266 0,125 > labelled S
>
> # the remaining
> Regards
>
>
>
>
> On Sat, Jul 25, 2009 at 5:32 PM, Tal Galili <tal.galili at gmail.com>
wrote:
>
> > Sure,
> >
> > Here is an example:
> >
> > # get some random data to play with
> > x <- runif(100)
> > y <- runif(100)
> > labels.to.plot <- sample(c("A","B"), 100, replace = T)
> >
> > # set up the window, play them one by one to see what they do
> > plot.window(ylim = c(0,1), xlim = c(0,1))
> > plot.new()
> > axis(1)
> > axis(2)
> > box()
> >
> > # plot the things you wished to plot, where you wanted them plotted
> > text(x, y , labels = labels.to.plot)
> >
> >
> >
> > Cheers,
> > Tal
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Sat, Jul 25, 2009 at 7:20 PM, Khaled OUANES <kouanes at gmail.com>
wrote:
> >
> >> hey
> >> thanks for the answer but I couldn't achieve it? would you explain a
bit
> >> more?
> >> I have like 300 points to label!
> >> thanks
> >>
> >
> >
> >
> > --
> > ----------------------------------------------
> >
> >
> > My contact information:
> > Tal Galili
> > Phone number: 972-50-3373767
> > FaceBook: Tal Galili
> > My Blogs:
> > http://www.r-statistics.com/
> > http://www.talgalili.com
> > http://www.biostatistics.co.il
> >
> >
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list