Graphics Programs Reference
In-Depth Information
Draw the lines by simply plugging in the two columns into lines() . Also
specify color ( col ) and line width ( lwd ).
lines(faketrace$longitude, faketrace$latitude, col=”#bb4cd4”, lwd=2)
Now also add dots, exactly like you just did with the Costco locations, for
the graphic in Figure 8-7.
symbols(faketrace$longitude, faketrace$latitude, lwd=1, bg=”#bb4cd4”,
fg=”#ffffff”, circles=rep(1, length(faketrace$longitude)), inches=0.05,
add=TRUE)
FIGurE 8-7 Drawing a location trace
After those seven days and nights as a spy for the Fakesville government, I
decided it wasn't for me. It's just not as glamorous as James Bond makes
it out to be. However, I did make connections in all the countries I visited.
It could be interesting to draw lines from my location to all the others, as
shown in Figure 8-8.
map(database=”world”, col=”#cccccc”)
for (i in 2:length(faketrace$longitude)-1) {
lngs <- c(faketrace$longitude[8], faketrace$longitude[i])
lats <- c(faketrace$latitude[8], faketrace$latitude[i])
lines(lngs, lats, col=”#bb4cd4”, lwd=2)
}
Search WWH ::




Custom Search