<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">Hi,</p>
<p style="margin:0px 0px 1.2em!important">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:</p>
<ol style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px">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 <strong>scale_colour_manual ()</strong> from the ggplot2 package as well as <strong>scalebar()</strong> from ggsn package but haven’t really been successful. The code I used is as follows:</li>
</ol>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-javascript" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(0,0,0);background:rgb(248,248,255)">
<span class="hljs-comment" style="color:rgb(64,128,128);font-style:italic">// Used ggR() to plot the map</span>
map <- ggR(p224r63_2011_uc$map, geom_raster = TRUE)
<span class="hljs-comment" style="color:rgb(64,128,128);font-style:italic">// Then used custom theme elements to add other features</span>
map + scale_x_continuous(expand = c(<span class="hljs-number" style="color:rgb(64,160,112)">0</span>, <span class="hljs-number" style="color:rgb(64,160,112)">0</span>)) + scale_y_continuous(expand = c(<span class="hljs-number" style="color:rgb(64,160,112)">0</span>, <span class="hljs-number" style="color:rgb(64,160,112)">0</span>)) + labs(x = NULL, y = NULL) + theme(axis.text.x = element_text(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey40"</span>, size = <span class="hljs-number" style="color:rgb(64,160,112)">6</span>), axis.text.y = element_text(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey40"</span>, size = <span class="hljs-number" style="color:rgb(64,160,112)">6</span>, angle = <span class="hljs-number" style="color:rgb(64,160,112)">90</span>, hjust = <span class="hljs-number" style="color:rgb(64,160,112)">0.5</span>), legend.text = element_text(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey10"</span>, size = <span class="hljs-number" style="color:rgb(64,160,112)">6</span>), legend.title = element_text(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey10"</span>, size = <span class="hljs-number" style="color:rgb(64,160,112)">8</span>, face = <span class="hljs-string" style="color:rgb(33,145,97)">"bold"</span>), axis.ticks = element_line(colour = <span class="hljs-string" style="color:rgb(33,145,97)">"grey40"</span>))
</code></pre>
<p style="margin:0px 0px 1.2em!important">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.</p>
<ol style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px"><p style="margin:0px 0px 1.2em!important;margin:0.5em 0px!important">How do I set a simple scale bar like the one used in the book and/or the variant of it in ggplot2?</p>
</li>
<li style="margin:0.5em 0px"><p style="margin:0px 0px 1.2em!important;margin:0.5em 0px!important">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?</p>
</li>
</ol>
<p style="margin:0px 0px 1.2em!important">Regards</p>
<div title="MDH:PGRpdj5IaSw8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PlRoZSBib29rIGlzIGF3ZXNvbWUgYW5k
IHZlcnkgaGVscGZ1bC4gSSBhbSBkb2luZyBwcmFjdGljZSBhbmQgbm93IGluIENoYXB0ZXIgOC4g
VGhlIGNvZGUgcnVucyB2ZXJ5IHdlbGwgYnV0IEkgaGF2ZSB0aHJlZSBxdWVzdGlvbnMgY29uY2Vy
bmluZyB0aGUgZmluYWwgbWFwIHByb2R1Y2VkOjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY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