title: How to create custom color palette to be used by scale_fill_manual()
body: <p>Consider the following code that makes a bar chart with a purple color palette   </p>
  
  <pre><code>library(dplyr)
  library(ggplot2)
  
  dd &lt;- mpg %&gt;% 
          group_by(manufacturer, cyl) %&gt;% 
          summarise(n = n()) %&gt;%
          ungroup() 
  
  mm &lt;- dd %&gt;%
          group_by(manufacturer) %&gt;%
          summarise(mcyl = weighted.mean(cyl, n)) %&gt;%
          arrange(mcyl) %&gt;%
          ungroup()
  
  dd %&gt;% left_join(mm) %&gt;%
          ggplot(mapping = aes(x = reorder(manufacturer, mcyl), y = n, fill = factor(cyl))) + 
          geom_bar(stat = "identity", position = "fill") +
          coord_flip() +
          scale_fill_brewer(palette = "Purples")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rb4Xw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rb4Xw.png" alt="enter image description here"></a></p>
  
  <p><strong>Question</strong>: How can I make the palette for Audi red ("Reds") and for Ford blue ("Blues"), while keeping the others purple ("Purples")? </p>
  
  <p>What is the most convenient (preferably tidyverse) way to put these red/blue/purple palettes in a variable and passing it to <code>scale_fill_manual()</code> (as explained <a href="https://stackoverflow.com/questions/3079264/using-a-pre-defined-color-palette-in-ggplot"><strong>in this related Q&amp;A</strong></a>)?</p>