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


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s