Maps with ggmap

Ggplot2 is a powerful and awesome tool to visualize data and statistical analysis in R. Today I’d like to show you how to plot spatial data over static maps from Google Maps, OpenStreetMap, Stamen Maps, or CloudMade Maps. Ggmap which allows us to visualize any part of the world with a simple code. This function download coordinates with get_map() and then plot the map. qmplot() is the ggmap equivalent to qplot() for quick plotting maps and qmap() is a wraper for ggmap() and get_map().

In the example below we’re going to represent ecuador earthquakes from April 23. Data can be downloaded from

EQ <- read.csv("all_day.csv")
EQ <- EQ[grepl("Ecuador", EQ$place),]
EcuadorMap <- qmap("ecuador", zoom=6)
EcuadorMap +
geom_point(aes(x=longitude, y=latitude, size=mag),
data=EQ, color="#ff7f00", alpha=0.7) +
labs(title="Ecuador Earthquakes",x="Longitude",y="Latitude",size="Magnitude")



For more information and examples see