[R] How to change labels in scatterplot?

John Fox jfox at mcmaster.ca
Tue Feb 8 16:50:01 CET 2011


Dear Erich,

The reason that this fails is the id.n is applied separately to each group,
and nrow(Prestige) is of course larger than any of the group sizes. Other
than plotting the labels yourself, after setting reset.par=FALSE, I don't
see a simple way to get scatterplot() to do what you want. BTW, it's easier
to define the groups in the model formula using | .

Regards,
 John

--------------------------------
John Fox
Senator William McMaster
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox




> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of Erich Striessnig
> Sent: February-08-11 9:55 AM
> To: r-help at r-project.org
> Subject: [R] How to change labels in scatterplot?
> 
> Dear all,
> 
> I'm trying to use "scatterplot" from package "car" to get a scatterplot
> with row-names as labels and I want my data to be divided into two groups
> defined by the column "tresh". Leaving away the groups-command gives me
> the right labels but they are not distinguished by colors according to
> "tresh". Does anybody know why the following example doesn't work?
> 
> Prestige2 <- transform(Prestige,thresh=(income>5000))
> attach(Prestige2)
> scatterplot(income~education,data=Prestige2,
>             xlab="Education",ylab="Income",cex.lab=1.2,
>             smooth=TRUE,spread=FALSE,reg.line=TRUE,lwd=2,
>             groups=thresh,by.groups=TRUE,legend.plot=TRUE,
>             id.n=nrow(Prestige),id.cex=0.8)
> 
> Cheers,
> Erich
> 
> 	[[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