The scale bar doesn't appear on my drawing
liufan612 opened this issue · 0 comments
my code is below,and my figure
ggplot()+
geom_raster(data=pm25_80_99_, aes(long, lat, fill=value))+
geom_sf(data=glo_shape, fill = NA, color = "black", size = 0.2)+
scale_fill_distiller(type = "div", palette = "RdYlBu",direction = -1,na.value=NA)+
labs(x ='Longitude',y="Latitude",
title = "PM2.5_1980_1999_95th",
)+
coord_sf(expand = FALSE,ylim = c(-60, 90))+
scale_x_continuous(limits = c(-180, 180), breaks = seq(-180, 180, 60))+
scale_y_continuous(limits = c(-60, 90), breaks = seq(-60, 90, 30))+
labs(fill="value")+
theme_bw()+theme(
axis.text.x = element_text(margin=unit(c(0.5,0.5,0.5,0.5), "cm")),
axis.text.y = element_text(margin=unit(c(0.5,0.5,0.5,0.5), "cm")),
axis.line = element_line(colour = "black"),
legend.position = "right",
legend.background = element_rect(fill="transparent", size=2, linetype="blank", colour ="darkblue"),
legend.text = element_text(colour="black", size=8, face="plain"),
legend.title= element_text(colour="black", size=8, face="plain"),
plot.margin = unit(c(0.5,0.5,0,0), "cm"),
plot.title = element_text(face="bold",size=20,hjust = 0.5,vjust=0),
axis.title = element_text(size = 12, face = 'bold'),
axis.text = element_text(size = 10) #
)+
annotation_north_arrow(
height = unit(0.5, "cm"),
width = unit(0.5, "cm"),
pad_x = unit(0.25, "in"),
pad_y = unit(1.9, "in"),
rotation = NULL, which_north='false',)+
ggsn::scalebar(data=pm25_80_99_,dist = 2000,dist_unit ='km', transform = TRUE, model = "WGS84",
st.size = 50, location = 'bottomleft',y.min = -60, y.max = 90, x.min = -180, x.max = 180,
box.fill = c("yellow", "black"), st.color = "black",height=0.01)