how to show a plot without overlaying the text on top of the another text?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

how to show a plot without overlaying the text on top of the another text?

Marna Wagley
Hi R user,
I have created using metaNMDS (Nonmetirc Multidimensional Scaling, MDS) to
show species composition but some of the species are concentrated at some
of the sites so that the name of the species are overlaid and it was
almost impossible to read the species name in the figure. I was wondering how
we can show the plot without overlaying the text on top of another.
I used the following to create the plot. would you mind to suggest me?

comm.bc.mds <- metaMDS(dat, dist = "bray")
ordiplot(comm.bc.mds, display = "sites", type = "text")
ordipointlabel(comm.bc.mds,font = c(1, 1), cex = c(0.5, 0.3))

Thanks

MW

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: how to show a plot without overlaying the text on top of the another text?

Adams, Jean
The ggrepel package might help.

http://blog.revolutionanalytics.com/2016/01/avoid-overlapping-labels-in-ggplot2-charts.html

Jean

On Tue, Dec 13, 2016 at 5:37 PM, Marna Wagley <[hidden email]>
wrote:

> Hi R user,
> I have created using metaNMDS (Nonmetirc Multidimensional Scaling, MDS) to
> show species composition but some of the species are concentrated at some
> of the sites so that the name of the species are overlaid and it was
> almost impossible to read the species name in the figure. I was wondering
> how
> we can show the plot without overlaying the text on top of another.
> I used the following to create the plot. would you mind to suggest me?
>
> comm.bc.mds <- metaMDS(dat, dist = "bray")
> ordiplot(comm.bc.mds, display = "sites", type = "text")
> ordipointlabel(comm.bc.mds,font = c(1, 1), cex = c(0.5, 0.3))
>
> Thanks
>
> MW
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: how to show a plot without overlaying the text on top of the another text?

Jim Lemon-4
In reply to this post by Marna Wagley
Hi Marna,
Your request made me think that a simple manual label placing function
might be useful to some people.

placeLabels<-function(pointer=TRUE,cex=1,labelcol=par("fg"),
 bg="white",border=par("fg"),pointercol=par("fg")) {

 cat("Enter a blank label to finish\n")
 nextlabel<-"XXX"
 while(nchar(nextlabel)) {
  cat("Click on a data point\n")
  datumxy<-locator(1)
  cat("Click on the label position\n")
  labelxy<-locator(1)
  nextlabel<-readline("Enter the label - ")
  if(nchar(nextlabel)) {
   if(pointer) segments(datumxy$x,datumxy$y,labelxy$x,labelxy$y,
    col=pointercol)
   boxed.labels(labelxy$x,labelxy$y,nextlabel,col=labelcol,
    bg=bg,border=border)
  }
 }
}

All I have to do is work out how to get it to automatically switch
back to the console window for the label entry.

Jim


On Wed, Dec 14, 2016 at 10:37 AM, Marna Wagley <[hidden email]> wrote:

> Hi R user,
> I have created using metaNMDS (Nonmetirc Multidimensional Scaling, MDS) to
> show species composition but some of the species are concentrated at some
> of the sites so that the name of the species are overlaid and it was
> almost impossible to read the species name in the figure. I was wondering how
> we can show the plot without overlaying the text on top of another.
> I used the following to create the plot. would you mind to suggest me?
>
> comm.bc.mds <- metaMDS(dat, dist = "bray")
> ordiplot(comm.bc.mds, display = "sites", type = "text")
> ordipointlabel(comm.bc.mds,font = c(1, 1), cex = c(0.5, 0.3))
>
> Thanks
>
> MW
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: how to show a plot without overlaying the text on top of the another text?

glsnow
In reply to this post by Marna Wagley
Some tools that might help include spread.labels from the plotrix
package, spread.labs from the TeachingDemos package, and
dynIdentify/TkIdentify from the TeachingDemos package.

On Tue, Dec 13, 2016 at 4:37 PM, Marna Wagley <[hidden email]> wrote:

> Hi R user,
> I have created using metaNMDS (Nonmetirc Multidimensional Scaling, MDS) to
> show species composition but some of the species are concentrated at some
> of the sites so that the name of the species are overlaid and it was
> almost impossible to read the species name in the figure. I was wondering how
> we can show the plot without overlaying the text on top of another.
> I used the following to create the plot. would you mind to suggest me?
>
> comm.bc.mds <- metaMDS(dat, dist = "bray")
> ordiplot(comm.bc.mds, display = "sites", type = "text")
> ordipointlabel(comm.bc.mds,font = c(1, 1), cex = c(0.5, 0.3))
>
> Thanks
>
> MW
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: how to show a plot without overlaying the text on top of the another text?

Jim Lemon-4
In reply to this post by Marna Wagley
Hi Marna,
After a bit of experimenting I came up with the following function
that "flags" each point to be labeled an allows the operator to
manually place the label for that point:

placeLabels<-function(x,y,labels,pointer=TRUE,cex=1,labelcol=par("fg"),
 labelbg="white",border=par("fg"),pointercol=par("fg"),
 pch=1,col=1,bg="white",flagcol="red") {

 nlabels<-length(labels)
 if(length(labelcol) < nlabels) labelcol<-rep(labelcol,length.out=nlabels)
 if(length(labelbg) < nlabels) labelbg<-rep(labelbg,length.out=nlabels)
 if(length(border) < nlabels) border<-rep(border,length.out=nlabels)
 if(length(pointercol) < nlabels) pointercol<-rep(pointercol,length.out=nlabels)
 if(length(pch) < nlabels) pch<-rep(pch,length.out=nlabels)
 if(length(col) < nlabels) col<-rep(col,length.out=nlabels)
 if(length(bg) < nlabels) bg<-rep(bg,length.out=nlabels)
 for(i in 1:nlabels) {
  points(x[i],y[i],pch=19,col=flagcol)
  labelxy<-locator(1)
  if(pointer)
   segments(x[i],y[i],labelxy$x,labelxy$y,col=pointercol[i])
  boxed.labels(labelxy$x,labelxy$y,labels[i],
   col=labelcol[i],bg=labelbg[i],border=border[i])
  points(rep(x[i],2),rep(y[i],2),pch=c(19,pch[i]),
   col=c("white",col[i]),bg=c(NA,bg[i]))
 }
}
x<-rnorm(10)
y<-rnorm(10)
plot(x,y)
library(plotrix)
placeLabels(x,y,LETTERS[1:10],flagcol="purple")

Jim


On Wed, Dec 14, 2016 at 10:37 AM, Marna Wagley <[hidden email]> wrote:

> Hi R user,
> I have created using metaNMDS (Nonmetirc Multidimensional Scaling, MDS) to
> show species composition but some of the species are concentrated at some
> of the sites so that the name of the species are overlaid and it was
> almost impossible to read the species name in the figure. I was wondering how
> we can show the plot without overlaying the text on top of another.
> I used the following to create the plot. would you mind to suggest me?
>
> comm.bc.mds <- metaMDS(dat, dist = "bray")
> ordiplot(comm.bc.mds, display = "sites", type = "text")
> ordipointlabel(comm.bc.mds,font = c(1, 1), cex = c(0.5, 0.3))
>
> Thanks
>
> MW
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.