[RS-ecology] ADDING SCALE BAR AND CUSTOM COLOURS IN ggplot2

Rop Willy ropcwillies at gmail.com
Tue Jul 10 19:54:28 CEST 2018


Hi,

The book is awesome and very helpful. I am doing practice and now in
Chapter 8. The code runs very well but I have three questions concerning
the final map produced:

   1. When I plot the classification map using ggplot2 I’d like to use my
   own color scheme but don’t know how. I’ve tried using *scale_colour_manual
   ()* from the ggplot2 package as well as *scalebar()* from ggsn package
   but haven’t really been successful. The code I used is as follows:

// Used ggR() to plot the map

map <- ggR(p224r63_2011_uc$map, geom_raster = TRUE)
// Then used custom theme elements to add other features

map + scale_x_continuous(expand = c(0, 0)) + scale_y_continuous(expand
= c(0, 0)) + labs(x = NULL, y = NULL) + theme(axis.text.x =
element_text(colour = "grey40", size = 6), axis.text.y =
element_text(colour = "grey40", size = 6, angle = 90, hjust = 0.5),
legend.text = element_text(colour = "grey10", size = 6), legend.title
= element_text(colour = "grey10", size = 8, face = "bold"), axis.ticks
= element_line(colour = "grey40"))

How can I change the color scheme manually in ggplot2 instead of using
RColorBrewer and other palettes? NB: I’ve tried most options from Stack
Overflow and other references but nothing seems to work for me.

   1.

   How do I set a simple scale bar like the one used in the book and/or the
   variant of it in ggplot2?
   2.

   When I plot the map for the unsupervised classification (again in
   ggplot2) there’s a class called NA ( I suppose from unclassified pixels)
   that appear grey on the legend. Should it be there or should I remove it?
   If it is not necessary, how is it removed from the final map presentation?

Regards
​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-wuerzburg.de/pipermail/rs-ecology/attachments/20180710/9b1a6584/attachment.html>


More information about the RS-ecology mailing list