Nadya Nadya - 14 days ago 9
R Question

How to change size of a map in ggplot

airportsUS <- subset(airports, iso_country == "US" ) #select only US airports

map <- borders("usa", colour="black", fill="white", size = .3) #map USA continent

airportsmap <- ggplot(airportsUS) + map

print(airportsmap + geom_point(aes(x=airportsUS$longitude_deg,
y=airportsUS$latitude_deg),
shape=3, size = .1, color = "red")+
theme(legend.position = "top")+
ggtitle("Airports"))


The problem is when I print my map with airports, I can't see US continent, only my airports, and map of US so small, and I don't know how to "print" it in the middle of my field and make bigger.
Is that mean that I have too much data?
Thank you!

Answer

I am not quite sure what you want, but when you add scale_x_continuousand scale_y_continuouswith limits, you can make the mapped area smaller and "zoom in" to the US.

If you are interested in mapping, I suggest you have a look at tmap (https://cran.r-project.org/web/packages/tmap/tmap.pdf). It can produce point maps too.

airports <- read.csv("http://bl.ocks.org/mbostock/raw/7608400/airports.csv", stringsAsFactors=FALSE)
airportsUS <- airports
map <- borders("usa", colour="black", fill="white", size = .3) #map USA continent

airportsmap <- ggplot(airportsUS) + map 

print(airportsmap + geom_point(aes(x=airportsUS$longitude, 
                                   y=airportsUS$latitude), 
                               shape=3, size = .1, color = "red")+
        theme(legend.position = "top")+
        scale_x_continuous(limits = c(-125, -67))+
        scale_y_continuous(limits = c(25, 50))+
        ggtitle("Airports"))

enter image description here