first commit
[synclust.git] / R / graphics.R
CommitLineData
15d1825d
BA
1#draw (France or...) map with all sites of colors 'cols'
2drawMapWithSites = function(M, cols=rep(1,nrow(M)))
3{
4 xMin = range(M[,1])[1]
5 xMax = range(M[,1])[2]
6 yMin = range(M[,2])[1]
7 yMax = range(M[,2])[2]
8 par(mar=c(2,2,2,2))
9 plot(0,0,xlim=c(xMin,xMax),ylim=c(yMin,yMax),col="white")
10 #plot by color groups (limited to integers)
11 maxColor = max(cols)
12 for (i in 1:maxColor)
13 {
14 indices = (1:nrow(M))[cols==i]
15 if (length(indices) > 0)
16 points(M[indices,1],M[indices,2],col=i,xtitle=NULL)
17 }
18}
19
20#draw neighborhoods graph on top of a country map (or any other map)
21drawNeighborhoodGraph = function(M, NI)
22{
23 for (i in 1:length(NI))
24 {
25 for (j in NI[[i]])
26 lines(c(M[i,1],M[j,1]),c(M[i,2],M[j,2]))
27 }
28}
29
30#plot a matrix of curves (in rows)
31plotCurves = function(M, cols=rep(1,nrow(M)))
32{
33 n = nrow(M)
34 rg = c(min(M),max(M)) #range for plotting
35 for (i in 1:n)
36 {
37 plot(M[i,],col=cols[i],ylim=rg,type="l")
38 if (i < n) par(new=TRUE)
39 }
40}