Thanks very much Greg. 'fail miserably' - sounds like what I was
expecting. I appreciate the ideas and hadn't considered any of them. I
was looking to draw a line between centroid of one polygon and centroid
of the common area with overlapping polygon then move the polygon
further along the axis of that line I've defined. Multiple overlapping
polygons will be ugly.
I'll report back if I have any success.
thank you all
Michael

________________________________

From: Greg Snow [mailto:538280@gmail.com] 
Sent: March 12, 2013 2:46 PM
To: Folkes, Michael
Cc: r-help
Subject: Re: [R] funtion equivalent of jitter to move figures on device


In addition to the other suggestions that you have received you may want
to look at the spread.labs function in the TeachingDemos package and the
spread.labels function in the plotrix package.  These only spread in 1
dimension, but may be able to do what you want.  The thigmaphobe.labels
function in plotrix may be of help as well.  If none of these functions
does what you want then looking at the code may help with some ideas. 

Preventing overlap in 2 dimensions automatically while keeping things
close to a certain location is not a simple task.  I have written
functions that do well for a particular dataset, but then fail miserably
on a different one.  If there is only a little overlap and that can be
solved by moving just one subplot then an algorithm that may work is to
start with the smallest polygon and put its plot on the map and store
the coordinates that it covers, then try the next smallest polygon and
if it overlaps move it a little in the direction away from the center of
the one it overlaps with until they don't overlap, keep going in the
order smallest to largest (since larger polygons should have more
flexibility in where you can move things).

Another option that sometimes works (and sometimes fails with strange
results) is to create a function that for a give set of "centers" will
calculate the degree of overlap and the distance from the centers to the
desired location and returns a weighted sum of these values.  You then
use that function with the optim function it can give you location for
the centers of the subplots.  Getting the weighting correct is
difficult, weight the overlap too much and it will spread the plots out
way too much, don't give it enough weight and it will still leave you
with some overlap.


On Tue, Mar 12, 2013 at 9:04 AM, Folkes, Michael
<Michael.Folkes@dfo-mpo.gc.ca> wrote:


	hello all,
	I'm overlaying numerous scatter plots onto a map (done in
PBSmodelling). In this case I'm placing each plot by setting par(fig) to
the centroid of map polygons. The location/mapping part is not so
important. There are cases of small overlaps for some plots (ie figures)
so I'm keen to write or find a function that moves my small scatter
plots so they don't overlap. A little like jitter, but not random in
behaviour, it needs to move away from the plots it's overlapping.
	
	thanks to all
	Michael
	_______________________________________________________
	Michael Folkes
	Salmon Stock Assessment
	Canadian Dept. of Fisheries & Oceans
	Pacific Biological Station
	
	
	        [[alternative HTML version deleted]]
	
	______________________________________________
	R-help@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.
	




-- 
Gregory (Greg) L. Snow Ph.D.
538280@gmail.com 

	[[alternative HTML version deleted]]

