title: Order grouped scatterplot by mean
body: <p>I am plotting a <code>geom_point</code> for several groups (<code>Loc</code>) and want in addition a line that indicates the mean of the points for each group. The groups should be ordered based on the mean of the <code>Size</code> for each group. I am trying to do this by <code>reorder(Loc, Size.Mean)</code> but it does not reorder.</p>
  <pre><code>  ggplot(data,aes(Loc,Size,color=Loc)) + 
    geom_point() + 
    geom_point(data %&gt;% 
                 group_by(Loc) %&gt;% 
                 summarise(Size.Mean = mean(Size)),
               mapping = aes(y = Size.Mean, x = reorder(Loc, Size.Mean)),
               color = &quot;black&quot;, shape = '-') +
    theme_pubr(base_size=8) + 
    scale_y_continuous(trans=&quot;log10&quot;) + 
    theme(axis.text.x = element_text(angle = 90,hjust = 1)) +
    theme(legend.position = &quot;none&quot;)
  </code></pre>