Failed to add label

30 views
Skip to first unread message

Jakty Kusuma

unread,
Oct 25, 2022, 8:47:25 AM10/25/22
to ggplot2
Hi everyone,

I'm trying to create a map with and I indicate points on particular places with a label in it. The map was successfully created. However, when I tried to add a label, the label name on a plot did not appear.

Here's the code I used:

coord5 = read.table("Coordinates_maluku_all.txt", header = TRUE)

maluku <- ggplot() + geom_polygon(data = shp, aes(x = long, y = lat, group = group),
                          colour = "black", fill = "grey80") +
  coord_cartesian(xlim = c(126.600,131.783), ylim = c(-5.583,2.776)) +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
        panel.background = element_blank())

maluku_comb <- maluku + geom_point(data = coord5, aes(x = Longitude, y = Latitude), shape = 19, size = 3) +
  scale_bar(lon = 127.300, lat = -5.57,
          distance_lon = 100, distance_lat = 30, distance_legend = 40,
          dist_unit = "km", orientation = FALSE)

maluku_comb + geom_text(aes(label = Name))

Here's the shp file and coordinates (*.txt) file that I used:

I also used a function available here to create a bar scale.

Any kind of help would be greatly appreciated.

Thank you so much
Reply all
Reply to author
Forward
0 new messages