Description Usage Arguments Examples
Define a function that iteratively shift values in a vector avoid overlap
1 2 | minimizeoverlap(x, maxiterations = 100, radius = 0.5, shift = 0.1,
minval = -Inf, maxval = Inf)
|
x |
vector of values to be spaced out |
maxiterations |
the maximum number of iterations to try |
radius |
how big a a radius of repulsion should we give to each value |
shift |
what is the maximum amount we should shift the value |
minval |
what is the minimum allowed value after shifting |
maxval |
what is the maximum allowed value after shifting |
1 2 3 4 5 6 7 8 9 10 11 12 13 | minval = 0 - 0.5
maxval = 20 + 0.5
plot(1,type='n',ann=F,xaxt='n',yaxt='n',xlim=c(0,40),ylim=c(0,20),xaxs='i',yaxs='i')
# pick vals between 1 and 100
x = runif(10,0,20)
y = minimizeoverlap(x,maxiterations=100,radius=.5,shift=0.1,minval=minval,maxval=maxval)
for (i in 1:length(x))
{
plotCircle(1,x[i],.5)
plotCircle(2,y[i],.5)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.