0

According with @missuse answer to this question Plot bathymetry and coastline using ggplot2 and marmap

I generated this plot enter image description here

By this script

Bathy <- getNOAA.bathy(lon1 = 37, lon2 = 38.7,
                       lat1 = -45.5, lat2 = -47.3, resolution = 1)
Bathy <- as.matrix(Bathy)
class(Bathy) <- "matrix"

Bathydf <- as.data.frame(Bathy)
Bathydf <- rownames_to_column(Bathydf, var = "Longitude")
Bathydf <- gather(Bathydf,Latitude,Depth, -1)
Bathydf <- mutate_all(.tbl = Bathydf, funs(as.numeric))


ggplot(data = ctd, aes(x = Longitude, y = Latitude)) +
  geom_raster(aes(fill = Chla)) +
  scale_fill_gradientn(colours = rev(my_colours)) +
  geom_contour(aes(z = Chla), binwidth = 2, colour = "red", alpha = 0.2) +
  geom_contour(aes(z = Chla), breaks = 0.1, colour = "darkgrey") +
  geom_contour(aes(z = Chla), breaks = 0.2, colour = "darkgrey") +
  geom_contour(aes(z = Chla), breaks = 0.3, colour = "black") +

  geom_contour(data = subset(Bathydf, Depth < 0),aes(x = Longitude, y = Latitude, z = Depth),
               bins = 10, colour = "darkgray") +
  stat_contour(data = subset(Bathydf, Depth >= 0),geom="polygon",
               aes(z = Depth), fill = "black") +

  geom_contour(data = Bathydf, aes(z = Depth), breaks = 1000, colour = "black", alpha = 1) + 
  geom_point(data = ctd, aes(x = Longitude, y = Latitude),
             colour = 'black', size = 3, alpha = 1, shape = 15) +


  theme(panel.background = element_blank()) +
  theme(aspect.ratio=1)

It works, but I am not sure if using stat_contour() is the best way to plot the areas. Furthermore, plotting the areas of the islands, it colours also some parts of them, making the shape wired. Do you think to use stat_contour() is the best way to plot the areas, and do you know why it plots also the wired spots around the big black area?

Strobila
  • 317
  • 3
  • 15

1 Answers1

1

Have you looked at my solution in this post?

Have you checked the help file for marmap::autoplot.bathy? Have you looked at the examples there, and especially the geom="contour" argument? Is it not doing what you want to achieve?

Benoit
  • 1,154
  • 8
  • 11