You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am plotting a map with ggplot2 and would like to have a rectangle surrounding it. I have tried to create the rectangle using geom_rect function, but whenever I include coord_sf function in the code chunk, the rectangle disappears. Below are the maps I got with the following codes. Classes of zone_map and ecoregion_polygon objects are "sf" and both are read in using st_read function.
ggplot() +
geom_sf(data = zone_map, color = "black", fill = gray62_transparent) +
geom_sf(data = ecoregion_polygon, color = "black", fill = burlywood1_transparent) +
geom_rect(aes(xmin = 20, xmax = 50, ymin = 33, ymax = 47), color = "black", fill = NA)
ggplot() +
geom_sf(data = zone_map, color = "black", fill = gray62_transparent) +
geom_sf(data = ecoregion_polygon, color = "black", fill = burlywood1_transparent) +
geom_rect(aes(xmin = 20, xmax = 50, ymin = 33, ymax = 47), color = "black", fill = NA) +
coord_sf(crs = "+proj=laea +lat_0=38 +lon_0=35")
As you see in the second map, the geom_rect rectangle disappears upon addition of coord_sf line. How can I solve this issue? I have tried to create another polygon using st_polygon function, but I obtained the same results. I also tried setting both objects' crs as the azimuthal "+proj=laea +lat_0=38 +lon_0=35" projection, which I want to plot my map in, and I got the same results. Below are the st_crs outputs of zone_map and ecoregion_polygon objects.
I am plotting a map with
ggplot2
and would like to have a rectangle surrounding it. I have tried to create the rectangle usinggeom_rect
function, but whenever I includecoord_sf
function in the code chunk, the rectangle disappears. Below are the maps I got with the following codes. Classes of zone_map and ecoregion_polygon objects are "sf" and both are read in usingst_read
function.As you see in the second map, the
geom_rect
rectangle disappears upon addition ofcoord_sf
line. How can I solve this issue? I have tried to create another polygon usingst_polygon
function, but I obtained the same results. I also tried setting both objects' crs as the azimuthal"+proj=laea +lat_0=38 +lon_0=35"
projection, which I want to plot my map in, and I got the same results. Below are thest_crs
outputs of zone_map and ecoregion_polygon objects.The text was updated successfully, but these errors were encountered: