I'd like to create a map in ggplot2 with my target coordinates, the north arrow and scale bar for example, but despite the ggsave() function saving the last plot, it doesn't work in mymap.png image.
In my example:
#Packages
library(ggplot2)
library(ggsn)
# Get data set - x any are the points
all.stands.predict<-read.csv("https://raw.githubusercontent.com/Leprechault/trash/main/prediction__bug_2021-03-18.csv")
all.stands.predict<-all.stands.predict[all.stands.predict[,3]=="VILA PALMA",] # Area selection
#Create a map
gg <- ggplot() +
geom_point(data=all.stands.predict,
aes(x=x, y=y), color="red") +
xlab("Latitude") + ylab("Longitude") +
theme_bw()
#Add a scale bar.
gg <- gg + scalebar(location="bottomright",y.min=max(all.stands.predict$y)-0.001, y.max=max(all.stands.predict$y),
x.min=max(all.stands.predict$x)-0.001, x.max=max(all.stands.predict$y), model='WGS84',
transform=TRUE)
#
#Add a north arrow
north2(gg, 0.85, 0.85, symbol = 10)
#Save image in png
ggsave("mymap.png", dpi=300, width = 20, height = 20)
#
When I inspected my "mymap.png" image created, just the north arrow is represented and looks like this:
Please, any ideas for saved all the map elements?
Thanks in advance!

northwithdata=NULLlike thisgg + north(...). May this help, I would try out some example map when time allow.#Add a north arrow gg+north(data=NULL, 0.85, 0.85, symbol = 10) Error in north(data = NULL, 0.85, 0.85, symbol = 10) : argumento "x.min" ausente, sem padrão