This post has NOT been accepted by the mailing list yet.
Hi everyone,
i got problems with overlapping labels in a plot. when i plot the results from a multiple correspondence analysis most of the points and the assaociated labels overlap, as you can see in the screenshot posted below. is there any possibility to move the points? thanks in advance! |
This post has NOT been accepted by the mailing list yet.
John,
Look at thigmophobe.labels() in plotrix, or pointLabel() in maptools. greetings remko |
Hi Remko,
thanks for your answer. but i do not really understand how to use the commands. if i want to use thigmophobe.labels(x,y,) do i need to identify the xy coordinates for each point first and then manually move every point? and if i neet to do so how to use the identify() function? or is there any possibility to automatically place the labels in the best position? >MatArab <- as.matrix(ende[2:12]) >MatArab >MCAArab <- mjca(MatArab, nd = 2, lambda = "JCA", maxit = 50, epsilon = 0.0001) >plot(MCAArab, dim = c(1,2), map = "symmetric", centroids = TRUE, + what = c("none", "all"), mass = c(FALSE, FALSE), + contrib = c("none", "none"), col = c("#000000", "#FF0000")) <http://r.789695.n4.nabble.com/file/n4659710/lllll.jpeg> thanks a lot!! |
On 02/27/2013 05:20 AM, john55 wrote:
> Hi Remko, > > thanks for your answer. but i do > not really understand how to use the commands. > if i want to use thigmophobe.labels(x,y,) do i need to identify the xy > coordinates for each point first and then manually move every point? and if > i neet to do so how to use the identify() function? > or is there any possibility to automatically place the labels in the best > position? > >> MatArab<- as.matrix(ende[2:12]) >> MatArab >> MCAArab<- mjca(MatArab, nd = 2, lambda = "JCA", maxit = 50, epsilon = > 0.0001) > >plot(MCAArab, dim = c(1,2), map = "symmetric", centroids = TRUE, > + what = c("none", "all"), mass = c(FALSE, FALSE), > + contrib = c("none", "none"), col = c("#000000", "#FF0000")) > > <http://r.789695.n4.nabble.com/file/n4659710/lllll.jpeg> > Looking at your example, it is clear that thigmophobe.labels will not get all of the labels right. However, it would only be necessary to manually change a few label positions to get it right. Say your coordinates are labelled "x" nd "y". First get the offsets: textpos<-thigmophobe(x,y) I count eight labels that need to be moved. Take the two overlapping labels at about x=c(-0.75,-0.55) and y=c(0.2,0.2). These two will probably be left overlapping by thigmophobe, probably both with a textpos value of 4. Change the textpos value of the leftmost label to 2. Then replot with thigmophobe labels using text.pos=textpos. Do the same for the other labels until none overlap. If this is too much trouble, try the spread.lab function in the TeachingDemos package. It is a better algorithm, but not as easy to call as thigmophobe. Jim ______________________________________________ [hidden email] 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. |
In reply to this post by john55
I ran into a similar problem and wrote a basic package that uses force field simulation to adjust object location. While much improvement is possible, including integration with ggplot, etc. it seems to get the task accomplished. The following illustrates the functionality. If someone runs into the issue and searches for an answer, hopefully this will be of some assistance:
install.packages("FField") library(FField) FFieldPtRepDemo() |
This post has NOT been accepted by the mailing list yet.
Hello,
'FField' looks nice but when I try to install the package, I get the following message. package ‘FField’ is available as a source package but not as a binary package ‘FField’ is not available (for R version 2.15.2) Any hint on how I can use FField? Thanks in advance, Jae |
There were some issues with the CRAN submission and I was confused about the earlier package availability. It is available now in source form (http://cran.r-project.org/web/packages/FField/index.html)
The sequence for the demo of label repulsion: install.packages("FField", type = "source") library(FField)
install.packages("ggplot2") install.packages("gridExtra") FFieldPtRepDemo() The code is quite self-explanatory: FFieldPtRepDemo For now there is no intelligent heuristics for a variety of areas and point distributions as I wanted to get something helpful to folks out quickly but I'll add these in the medium term. At this time I recommend scaling charts to 100x100 dimensions and slightly tweaking the default attraction and repulsion parameters as warranted.
Thank you, Greg On Fri, Jun 28, 2013 at 5:49 AM, kujchoe [via R] <[hidden email]> wrote: Hello, |
Free forum by Nabble | Edit this page |