Positioning Legend on Map using geom_sf

I am trying to position a legend on a map. I'm using the longitude and latitude to position it but it doesn't show up anywhere.

library(sf)                                                         
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
library(tidyverse)                                                  
#> -- Attaching packages -------------------------------------------- tidyverse 1.2.1 --
#> v ggplot2 3.0.0     v purrr   0.2.5
#> v tibble  1.4.2     v dplyr   0.7.8
#> v tidyr   0.8.1     v stringr 1.3.1
#> v readr   1.1.1     v forcats 0.3.0
#> -- Conflicts ----------------------------------------------- tidyverse_conflicts() --
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag()    masks stats::lag()
                                                                    
nc <- st_read(system.file("shape/nc.shp", package="sf"))            
#> Reading layer `nc' from data source `C:\Users\sazimmer\Documents\R\win-library\3.5\sf\shape\nc.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 100 features and 14 fields
#> geometry type:  MULTIPOLYGON
#> dimension:      XY
#> bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> epsg (SRID):    4267
#> proj4string:    +proj=longlat +datum=NAD27 +no_defs
                                                                    
nc %>% ggplot(aes(fill=AREA)) +                                     
geom_sf()                                                           

                                                                    
# I am just trying to put a legend in lower left corner             
# It should be about 84 degrees west (-84) and 35 degrees north (35)
nc %>% ggplot(aes(fill=AREA)) +                                     
geom_sf() +                                                         
theme(legend.position = c(-84, 35))                                 

On my phone so can't post a solution but I realized the position parameters are between 0 and 1 with (0,0) being the bottom left and (1,1) being the top right. Will post full solution later.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.