title: R ggplot2: colors for stat_ellipse and for categorical variables with several unique values
body: <p>I have an R dataframe similar to the following: </p>
  
  <pre><code>      group           x          y trait1      grp.x      grp.y
  ind1      3 -1.35155328  2.5388350      A     -1.1778170  2.2361359
  ind2      3 -1.38344150  2.1475588      B     -1.1778170  2.2361359
  ind3      3 -1.38859652  2.4959691      B     -1.1778170  2.2361359
  ind4      2 -0.09222147 -1.6956082      A     -0.8312698 -1.1864784
  ind5      2 -0.51072944 -0.4015302      B     -0.8312698 -1.1864784
  ind6      3 -1.33953852  2.3398774      B     -1.1778170  2.2361359
  ind7      3 -1.33566078  1.7296098      B     -1.1778170  2.2361359
  ind8      2 -0.58546568 -0.6147354      C     -0.8312698 -1.1864784
  ind9      2 -0.76524417 -0.9873662      C     -0.8312698 -1.1864784
  ind10     2 -0.01614503 -1.4883271      C     -0.8312698 -1.1864784
  ind11     1  7.37664013 -1.5121731      D     7.5796202 -0.7459455
  ind12     1  5.69439899  0.1074283      D     7.5796202 -0.7459455
  ind13     1  6.83721986 -0.9119275      D     7.5796202 -0.7459455
  ind14     1  9.66081076 -1.7497733      D     7.5796202 -0.7459455
  ind15     1  7.31749818 -1.3984597      E     7.5796202 -0.7459455
  </code></pre>
  
  <p>This dataframe contains the results of a cluster analysis, and each row corresponds with an individual sample. For each individual, I have values for group assignment (group), xy coordinates for the individual (x, y), values for a particular trait (trait1), and xy coordinates for the centroid of each group (grp.x, grp.y). </p>
  
  <p>I've used the following code to create the below plot with ggplot2: </p>
  
  <pre><code>ggplot(data) + 
    geom_point(aes(x=x, y=y, color=trait), size=1.5) +
    stat_ellipse(aes(x=x, y=y, color=group), type="norm", level=0.6) + 
    geom_point(mapping = aes(x=grp.x, y=grp.y), shape=17, cex=0.75) +
    geom_segment(aes(x=grp.x, y=grp.y, xend=x, yend=y), lwd=0.25) +
    geom_label(aes(x=grp.x, y=grp.y, label=group))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/eR0sk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eR0sk.jpg" alt="test plot"></a></p>
  
  <p>There are two things I would like to change about this plot but am stuck: </p>
  
  <ol>
  <li><p>Since the number corresponding with each group is shown as a label (e.g. 1, 2, 3), I don't really need the ellipse corresponding with each group to be color coded by group. Is there a way to use a single color for the ellipses described by stat_ellipse?</p></li>
  <li><p>My real data have many unique values for trait1 (rather than the 5 unique values shown here), and I would therefore like to create a palette of diverging colors to use for the fill of individual points, but I'm not sure that I am creating a palette properly, and where this should be implemented in my code (particularly given the context of question 1).</p></li>
  </ol>
  
  <p>I have attempted the following:</p>
  
  <pre><code>cols = colorRampPalette(brewer.pal(11,"Spectral"))(65)
  
  ggplot(data) + 
    geom_point(aes(x=x, y=y, color=trait), size=1.5) +
    stat_ellipse(aes(x=x, y=y, color=group), type="norm", level=0.6) + 
    geom_point(mapping = aes(x=grp.x, y=grp.y), shape=17, cex=0.75) +
    geom_segment(aes(x=grp.x, y=grp.y, xend=x, yend=y), lwd=0.25) +
    geom_label(aes(x=grp.x, y=grp.y, label=group)) +
    scale_color_brewer(palette=cols)
  </code></pre>
  
  <p>However, I get an error message for unknown palette type (I must be creating and/or calling my palette incorrectly), and the default color brewer palette R reverts to does not contain enough unique colors.</p>