I have managed to create a map of Europe below which works.
How can I add a dataset (which is in a .csv format) which has lat and lons. I made a dummy dataset below and I need to overlay the lat/lon for each
Place
and mark it with anx
formetricA
ando
formetricB
. Is there a way I can do this?The map comes up really small and the margins are really big. I tried to add
theme(plot.margin=grid::unit(c(0,0,0,0), "mm"))
based on this example from stack overflow R ggplot, remove white margins in ggsave/ggplot but when I add it beforecoord_sf(xlim = c(-40, 60), ylim = c(30, 90)) +
I get an Error
Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : polygon edge not found
and when I add it after, it doesn't change the margins to make the plot bigger. What can I do to make the figure bigger and the margins smaller?
library("ggplot2")
theme_set(theme_bw())
library("sf")
library("rnaturalearth")
library("rnaturalearthdata")
world <- ne_countries(scale = "medium", returnclass = "sf")
class(world)
ggplot(data = world) +
geom_sf(color = "black", fill = "grey") +
coord_sf(xlim = c(-40, 60), ylim = c(30, 90)) +
ggtitle("Europe") +
xlab('Longitude') + ylab('Latitude'))
Dataset:
Place MetricA MetricB Lat Lon
A x 55 -40
B x 60 -20
C x 75 18
D x x 68 3
E x 35 18
F x 74 42
G x 62 -26
H x 30 -30
I x x 69 15