Graphics Programs Reference
In-Depth Information
In Figure 8-3, the unfilled circles and the map were all the same color and
line width, so everything blended together, but with the right colors, you
can make the data sit front and center.
It's not bad for a few lines of code. Costco has clearly focused on opening
locations on the coasts with clusters in southern and northern California,
northwest Washington, and in the northeast of the country.
However, there is a glaring omission here. Well, two of them actually.
Where are Alaska and Hawaii? They're part of the United States, too, but
are nowhere to be found even though you use the “state” database with
map() . The two states are actually in the “world” database, so if you want to
see Costco locations in Alaska in Hawaii, you need to map the entire world,
as shown in Figure 8-5.
map(database=”world”, col=”#cccccc”)
symbols(costcos$Longitude, costcos$Latitude, bg=”#e2373f”, fg=”#ffffff”,
lwd=0.3, circles=rep(1, length(costcos$Longitude)),
inches=0.03, add=TRUE)
With R, when in
doubt, always
jump to the
documentation for
the function or
package you're
stuck on by
preceding the
name with a
question mark.
FIGurE 8-5 World map of Costco locations
It's a waste of space, I know. There are options that you can mess around
with, which you can find in the documentation, but you can edit the rest in
Illustrator to zoom in on the United States or remove the other countries
from view.
Search WWH ::




Custom Search