1 #' Draw (France or...) map with all sites of colors 'cols'
3 #' @param M Coordinates matrix (in columns)
4 #' @param cols Vector of colors for each row of M [default: all black]
7 drawMapWithSites = function(M, cols=rep(1,nrow(M)))
10 xMax = range(M[,1])[2]
11 yMin = range(M[,2])[1]
12 yMax = range(M[,2])[2]
14 plot(0,0,xlim=c(xMin,xMax),ylim=c(yMin,yMax),col="white")
15 #plot by color groups (limited to integers)
19 indices = (1:nrow(M))[cols==i]
20 if (length(indices) > 0)
21 points(M[indices,1],M[indices,2],col=i,xtitle=NULL)
25 #' Draw neighborhoods graph on top of a country map (or any other map)
27 #' @param M Coordinates matrix (in columns)
28 #' @param NI Neighborhoods of M rows (list of integer vectors)
31 drawNeighborhoodGraph = function(M, NI)
33 for (i in 1:length(NI))
36 lines(c(M[i,1],M[j,1]),c(M[i,2],M[j,2]))
40 #' Plot a matrix of curves (in rows)
42 #' @param M Coordinates matrix (in columns)
43 #' @param cols Vector of colors for each row of M [default: all black]
46 plotCurves = function(M, cols=rep(1,nrow(M)))
49 rg = c(min(M),max(M)) #range for plotting
52 plot(M[i,],col=cols[i],ylim=rg,type="l")
53 if (i < n) par(new=TRUE)