<p>Your command looks like it creates a ggplot2 object, so it should be possible to remove the symbol via <code>guides</code>, setting the associated aesthetic to <code>&quot;none&quot;</code>:</p>
<pre><code>Vln_plot &lt;- VlnPlot(object, 
                    features = c(&quot;Mcidas&quot;), 
                    cols = c(&quot;coral1&quot;, &quot;cadetblue&quot;, &quot;cadetblue2&quot;), 
                    split.by = &quot;genotype&quot;,
                    assay = &quot;RNA&quot;,
                    pt.size = 0,
                    log = TRUE) + 
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = &quot;blue&quot;,
               position = position_dodge(0.9)) +
  guides(color = &quot;none&quot;)
</code></pre>
<p>If that doesn't work, try telling the <code>stat_summary</code> command to disable the legend via <code>show.legend = FALSE</code>:</p>
<pre><code>Vln_plot &lt;- VlnPlot(object, 
                    features = c(&quot;Mcidas&quot;), 
                    cols = c(&quot;coral1&quot;, &quot;cadetblue&quot;, &quot;cadetblue2&quot;), 
                    split.by = &quot;genotype&quot;,
                    assay = &quot;RNA&quot;,
                    pt.size = 0,
                    log = TRUE) + 
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = &quot;blue&quot;,
               position = position_dodge(0.9), show.legend = FALSE) 
</code></pre>

CC BY-SA 4.0
2023-02-03T18:03:54.490Z
2023-02-03T18:03:54.490Z
gringer
<p>If you can provide a <a href="https://stackoverflow.com/help/minimal-reproducible-example">minimal reproducible example</a> with a 'cut-down' version of your data it would be a lot easier to answer your question. I have an example from a similar question on stackoverflow (<a href="https://stackoverflow.com/a/73696447/12957340">https://stackoverflow.com/a/73696447/12957340</a>) that illustrates one approach to your problem:</p>
<pre class="lang-r prettyprint-override"><code># Load libraries
library(tidyverse)

# Load example data
raw_data &lt;- structure(list(Type = c(&quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, 
                                    &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, 
                                    &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EY&quot;, &quot;EY&quot;, 
                                    &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EY&quot;, &quot;EO&quot;, 
                                    &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, 
                                    &quot;EO&quot;, &quot;EO&quot;, &quot;EO&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, 
                                    &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, 
                                    &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, 
                                    &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;, &quot;Fe&quot;), 
                           Maturity = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                  2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                                  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                                  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                                  1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(&quot;Before&quot;, 
                                                                                                      &quot;After&quot;), class = &quot;factor&quot;), Mn = c(49.65414679, 30.42267647, 
                                                                                                                                          53.57468125, 58.38531743, 11.07088615, 45.10644112, 41.33779076, 
                                                                                                                                          18.77426257, 60.36149117, 67.0260032, 38.13116392, 69.58713059, 
                                                                                                                                          66.80825471, 30.34496525, 56.90875291, 72.37427455, 22.06855022, 
                                                                                                                                          39.26030375, 35.31067394, 24.95698024, 24.88586385, 34.65821779, 
                                                                                                                                          56.2750941, 19.56655377, 45.04117517, 44.04604616, 30.4130276, 
                                                                                                                                          15.76824315, 21.50636001, 27.25777212, 17.08214603, 14.17493713, 
                                                                                                                                          34.24593956, 12.39548126, 23.59787998, 38.42021152, 32.54843776, 
                                                                                                                                          18.47119505, 26.05687922, 32.97977895, 16.91703485, 30.0626039, 
                                                                                                                                          26.72724955, 17.69433512, 22.34314521, 16.73815161, 13.08749188, 
                                                                                                                                          19.60771131, 24.08865106, 34.57472809, 14.94650052, 32.60745327, 
                                                                                                                                          29.86439635, 20.71564742, 22.32568148, 18.37220522, 24.22830773, 
                                                                                                                                          20.91660251, 20.96486868, 34.25266591, 35.57200211, 14.5736099, 
                                                                                                                                          25.67187037, 27.7352539, 42.919751, 27.1949762, 18.94238981, 
                                                                                                                                          25.25867502, 31.66215867, 18.1734287, 24.41910112, 12.07438938, 
                                                                                                                                          12.85034127, 19.75012923, 35.96030792, 30.07986478, 38.91460672, 
                                                                                                                                          41.18492241, 41.68085289, 60.93940724, 49.77930187, 17.56806894, 
                                                                                                                                          37.13306953, 47.06926881, 85.62093648, 24.31500546, 22.049633, 
                                                                                                                                          40.42923285, 87.53339143, 37.08699364, 38.29525586, 28.00272281, 
                                                                                                                                          15.58855204, 37.14164977)), row.names = c(NA, -94L), class = c(&quot;tbl_df&quot;, 
                                                                                                                                                                                                         &quot;tbl&quot;, &quot;data.frame&quot;))
</code></pre>
<hr />
<p>Functions:</p>
<pre class="lang-r prettyprint-override"><code>summary_df &lt;- raw_data %&gt;%
  mutate(Maturity = ifelse(Maturity == &quot;Before&quot;, &quot;a&quot;, &quot;x&quot;)) %&gt;%
  group_by(Type, Maturity) %&gt;%
  summarise(max_val = max(density(Mn)[[1]]) + 4) %&gt;%
  ungroup()

median.stat &lt;- function(x){
  out &lt;- quantile(x, probs = c(0.5))
  names(out) &lt;- c(&quot;ymed&quot;)
  return(out) 
}
</code></pre>
<hr />
<p>Similar 'problematic' violin plot:</p>
<pre class="lang-r prettyprint-override"><code>ggplot(raw_data, aes(x = Type, y = Mn, fill = Maturity)) +
  geom_violin(trim = FALSE, position=&quot;dodge&quot;) + 
  geom_boxplot(width=.1, outlier.shape=NA, position=position_dodge(.9)) +  
  scale_y_continuous(breaks = seq(0, 100, 25)) +
  theme_classic() + 
  theme(axis.title.x = element_blank(),
        axis.ticks.x = element_blank()) + 
  labs(y=&quot;Percent Maturity&quot;, x= &quot;&quot;) +
  geom_text(data = summary_df,
            aes(label = Maturity,
                y = max_val,
                x = Type,
                group = Maturity),
            position = position_dodge(width = 0.9),
            check_overlap = TRUE,
            show.legend = FALSE,
            inherit.aes = FALSE) +
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = &quot;blue&quot;,
               position = position_dodge(0.9))
#&gt; Warning: The `fun.y` argument of `stat_summary()` is deprecated as of ggplot2 3.3.0.
#&gt; ℹ Please use the `fun` argument instead.
</code></pre>
<p><img src="https://i.sstatic.net/HUpkO.png" alt="" /></p>
<hr />
<p>Remove dots:</p>
<pre class="lang-r prettyprint-override"><code>ggplot(raw_data, aes(x = Type, y = Mn, fill = Maturity)) +
  geom_violin(trim = FALSE, position=&quot;dodge&quot;) + 
  geom_boxplot(width=.1, outlier.shape=NA, position=position_dodge(.9)) +  
  scale_y_continuous(breaks = seq(0, 100, 25)) +
  theme_classic() + 
  theme(axis.title.x = element_blank(),
        axis.ticks.x = element_blank()) + 
  labs(y=&quot;Percent Maturity&quot;, x= &quot;&quot;) +
  geom_text(data = summary_df,
            aes(label = Maturity,
                y = max_val,
                x = Type,
                group = Maturity),
            position = position_dodge(width = 0.9),
            check_overlap = TRUE,
            show.legend = FALSE,
            inherit.aes = FALSE) +
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = &quot;blue&quot;,
               position = position_dodge(0.9), key_glyph = &quot;blank&quot;)
</code></pre>
<p><img src="https://i.sstatic.net/UoS5n.png" alt="" /></p>
<hr />
<p>Remove dots, but keep 'colour' legend to specify what the dots represent:</p>
<pre class="lang-r prettyprint-override"><code>ggplot(raw_data, aes(x = Type, y = Mn, fill = Maturity)) +
  geom_violin(trim = FALSE, position=&quot;dodge&quot;) + 
  geom_boxplot(width=.1, outlier.shape=NA,  position=position_dodge(.9), key_glyph = &quot;boxplot&quot;) +  
  scale_y_continuous(breaks = seq(0, 100, 25)) +
  theme_classic() + 
  theme(axis.title.x = element_blank(),
        axis.ticks.x = element_blank()) + 
  labs(y=&quot;Percent Maturity&quot;, x= &quot;&quot;) +
  geom_text(data = summary_df,
            aes(label = Maturity,
                y = max_val,
                x = Type,
                group = Maturity),
            position = position_dodge(width = 0.9),
            check_overlap = TRUE,
            show.legend = FALSE,
            inherit.aes = FALSE) +
  stat_summary(aes(colour = &quot;Median&quot;), fun.y = median.stat, 
               geom='point', size = 10,
               position = position_dodge(0.9)) +
  scale_color_manual(values = &quot;blue&quot;, name = &quot;Statistics&quot;) +
  guides(fill = guide_legend(override.aes = list(shape = NA)))
</code></pre>
<p><img src="https://i.sstatic.net/TCa7O.png" alt="" /></p>
<p><sup>Created on 2023-02-08 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p>
<p>Hopefully this approach can be adapted to your use-case.</p>

CC BY-SA 4.0
2023-02-07T23:10:21.947Z
2023-02-08T00:53:29.307Z
2023-02-08T00:53:29.307Z
jared_mamrot
<p>I'm plotting scRNA data using Violin Plots.  I need to re-order the plots and add median dots.  My code is:</p>
<pre class="lang-r prettyprint-override"><code>Vln_plot &lt;- VlnPlot(object, 
                    features = c(&quot;Mcidas&quot;), 
                    cols = c(&quot;coral1&quot;, &quot;cadetblue&quot;, &quot;cadetblue2&quot;), 
                    split.by = &quot;genotype&quot;,
                    assay = &quot;RNA&quot;,
                    pt.size = 0,
                    log = TRUE) + 
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = &quot;blue&quot;,
               position = position_dodge(0.9)) 
  

Vln_plot<span class="math-container">$data$</span>split&lt;- factor(x = Vln_plot<span class="math-container">$data$</span>split,
                                 levels = c(&quot;WT&quot;, &quot;F7KO&quot;, &quot;F8HET&quot;))

Vln_plot

median.stat &lt;- function(x){
  out &lt;- quantile(x, probs = c(0.5))
  names(out) &lt;- c(&quot;ymed&quot;)
  return(out) 
}
</code></pre>
<p>and my output looks like:
<a href="https://i.sstatic.net/cRmvG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/cRmvG.png" alt="enter image description here" /></a></p>
<p>Is there any way to fix the legend so those dots aren't in each box?  I also need to figure out how to get rid of that x-axis tic mark and change the x axis label from Identity to something else.  Can anyone point me in the right direction on how to accomplish this?</p>

CC BY-SA 4.0
2023-02-03T12:22:08.913Z
Is there any way to give us an example with some sort of toy dataset we can use for testing? Various R libraries include example data, any chance you could provide such an example?
terdon
<r><seurat>
How do I change the legend for a Violin Plot with median dot
# How do I change the legend for a Violin Plot with median dot

(Asked by: username_0 on 2023-02-02)

I'm plotting scRNA data using Violin Plots.  I need to re-order the plots and add median dots.  My code is:
Vln_plot <- VlnPlot(object, 
                    features = c("Mcidas"), 
                    cols = c("coral1", "cadetblue", "cadetblue2"), 
                    split.by = "genotype",
                    assay = "RNA",
                    pt.size = 0,
                    log = TRUE) + 
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = "blue",
               position = position_dodge(0.9)) 
  

Vln_plot$data$split<- factor(x = Vln_plot$data$split,
                                 levels = c("WT", "F7KO", "F8HET"))

Vln_plot

median.stat <- function(x){
  out <- quantile(x, probs = c(0.5))
  names(out) <- c("ymed")
  return(out) 
}

and my output looks like:

Is there any way to fix the legend so those dots aren't in each box?  I also need to figure out how to get rid of that x-axis tic mark and change the x axis label from Identity to something else.  Can anyone point me in the right direction on how to accomplish this?

**Tags:** r, seurat
> **Comments:**
> **username_1**: Is there any way to give us an example with some sort of toy dataset we can use for testing? Various R libraries include example data, any chance you could provide such an example?  

---

## 2 answers

### Answer by username_2 on 2023-02-03. Score: 1 | Accepted answer

Your command looks like it creates a ggplot2 object, so it should be possible to remove the symbol via guides, setting the associated aesthetic to "none":
Vln_plot <- VlnPlot(object, 
                    features = c("Mcidas"), 
                    cols = c("coral1", "cadetblue", "cadetblue2"), 
                    split.by = "genotype",
                    assay = "RNA",
                    pt.size = 0,
                    log = TRUE) + 
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = "blue",
               position = position_dodge(0.9)) +
  guides(color = "none")

If that doesn't work, try telling the stat_summary command to disable the legend via show.legend = FALSE:
Vln_plot <- VlnPlot(object, 
                    features = c("Mcidas"), 
                    cols = c("coral1", "cadetblue", "cadetblue2"), 
                    split.by = "genotype",
                    assay = "RNA",
                    pt.size = 0,
                    log = TRUE) + 
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = "blue",
               position = position_dodge(0.9), show.legend = FALSE)


---

### Answer by username_3 on 2023-02-07. Score: 1

If you can provide a minimal reproducible example with a 'cut-down' version of your data it would be a lot easier to answer your question. I have an example from a similar question on stackoverflow (https://stackoverflow.com/a/73696447/12957340) that illustrates one approach to your problem:
# Load libraries
library(tidyverse)

# Load example data
raw_data <- structure(list(Type = c("EY", "EY", "EY", "EY", "EY", "EY", "EY", 
                                    "EY", "EY", "EY", "EY", "EY", "EO", "EO", "EO", "EO", "EO", "EO", 
                                    "EO", "EO", "EO", "EO", "EO", "EO", "EO", "EO", "EO", "EY", "EY", 
                                    "EY", "EY", "EY", "EY", "EY", "EY", "EY", "EY", "EY", "EY", "EO", 
                                    "EO", "EO", "EO", "EO", "EO", "EO", "EO", "EO", "EO", "EO", "EO", 
                                    "EO", "EO", "EO", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", 
                                    "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", 
                                    "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", 
                                    "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "Fe"), 
                           Maturity = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                  2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                                  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                                  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
                                                  1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
                                                  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Before", 
                                                                                                      "After"), class = "factor"), Mn = c(49.65414679, 30.42267647, 
                                                                                                                                          53.57468125, 58.38531743, 11.07088615, 45.10644112, 41.33779076, 
                                                                                                                                          18.77426257, 60.36149117, 67.0260032, 38.13116392, 69.58713059, 
                                                                                                                                          66.80825471, 30.34496525, 56.90875291, 72.37427455, 22.06855022, 
                                                                                                                                          39.26030375, 35.31067394, 24.95698024, 24.88586385, 34.65821779, 
                                                                                                                                          56.2750941, 19.56655377, 45.04117517, 44.04604616, 30.4130276, 
                                                                                                                                          15.76824315, 21.50636001, 27.25777212, 17.08214603, 14.17493713, 
                                                                                                                                          34.24593956, 12.39548126, 23.59787998, 38.42021152, 32.54843776, 
                                                                                                                                          18.47119505, 26.05687922, 32.97977895, 16.91703485, 30.0626039, 
                                                                                                                                          26.72724955, 17.69433512, 22.34314521, 16.73815161, 13.08749188, 
                                                                                                                                          19.60771131, 24.08865106, 34.57472809, 14.94650052, 32.60745327, 
                                                                                                                                          29.86439635, 20.71564742, 22.32568148, 18.37220522, 24.22830773, 
                                                                                                                                          20.91660251, 20.96486868, 34.25266591, 35.57200211, 14.5736099, 
                                                                                                                                          25.67187037, 27.7352539, 42.919751, 27.1949762, 18.94238981, 
                                                                                                                                          25.25867502, 31.66215867, 18.1734287, 24.41910112, 12.07438938, 
                                                                                                                                          12.85034127, 19.75012923, 35.96030792, 30.07986478, 38.91460672, 
                                                                                                                                          41.18492241, 41.68085289, 60.93940724, 49.77930187, 17.56806894, 
                                                                                                                                          37.13306953, 47.06926881, 85.62093648, 24.31500546, 22.049633, 
                                                                                                                                          40.42923285, 87.53339143, 37.08699364, 38.29525586, 28.00272281, 
                                                                                                                                          15.58855204, 37.14164977)), row.names = c(NA, -94L), class = c("tbl_df", 
                                                                                                                                                                                                         "tbl", "data.frame"))


Functions:
summary_df <- raw_data %>%
  mutate(Maturity = ifelse(Maturity == "Before", "a", "x")) %>%
  group_by(Type, Maturity) %>%
  summarise(max_val = max(density(Mn)[[1]]) + 4) %>%
  ungroup()

median.stat <- function(x){
  out <- quantile(x, probs = c(0.5))
  names(out) <- c("ymed")
  return(out) 
}


Similar 'problematic' violin plot:
ggplot(raw_data, aes(x = Type, y = Mn, fill = Maturity)) +
  geom_violin(trim = FALSE, position="dodge") + 
  geom_boxplot(width=.1, outlier.shape=NA, position=position_dodge(.9)) +  
  scale_y_continuous(breaks = seq(0, 100, 25)) +
  theme_classic() + 
  theme(axis.title.x = element_blank(),
        axis.ticks.x = element_blank()) + 
  labs(y="Percent Maturity", x= "") +
  geom_text(data = summary_df,
            aes(label = Maturity,
                y = max_val,
                x = Type,
                group = Maturity),
            position = position_dodge(width = 0.9),
            check_overlap = TRUE,
            show.legend = FALSE,
            inherit.aes = FALSE) +
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = "blue",
               position = position_dodge(0.9))
#> Warning: The `fun.y` argument of `stat_summary()` is deprecated as of ggplot2 3.3.0.
#> ℹ Please use the `fun` argument instead.



Remove dots:
ggplot(raw_data, aes(x = Type, y = Mn, fill = Maturity)) +
  geom_violin(trim = FALSE, position="dodge") + 
  geom_boxplot(width=.1, outlier.shape=NA, position=position_dodge(.9)) +  
  scale_y_continuous(breaks = seq(0, 100, 25)) +
  theme_classic() + 
  theme(axis.title.x = element_blank(),
        axis.ticks.x = element_blank()) + 
  labs(y="Percent Maturity", x= "") +
  geom_text(data = summary_df,
            aes(label = Maturity,
                y = max_val,
                x = Type,
                group = Maturity),
            position = position_dodge(width = 0.9),
            check_overlap = TRUE,
            show.legend = FALSE,
            inherit.aes = FALSE) +
  stat_summary(fun.y = median.stat, geom='point', size = 10, colour = "blue",
               position = position_dodge(0.9), key_glyph = "blank")



Remove dots, but keep 'colour' legend to specify what the dots represent:
ggplot(raw_data, aes(x = Type, y = Mn, fill = Maturity)) +
  geom_violin(trim = FALSE, position="dodge") + 
  geom_boxplot(width=.1, outlier.shape=NA,  position=position_dodge(.9), key_glyph = "boxplot") +  
  scale_y_continuous(breaks = seq(0, 100, 25)) +
  theme_classic() + 
  theme(axis.title.x = element_blank(),
        axis.ticks.x = element_blank()) + 
  labs(y="Percent Maturity", x= "") +
  geom_text(data = summary_df,
            aes(label = Maturity,
                y = max_val,
                x = Type,
                group = Maturity),
            position = position_dodge(width = 0.9),
            check_overlap = TRUE,
            show.legend = FALSE,
            inherit.aes = FALSE) +
  stat_summary(aes(colour = "Median"), fun.y = median.stat, 
               geom='point', size = 10,
               position = position_dodge(0.9)) +
  scale_color_manual(values = "blue", name = "Statistics") +
  guides(fill = guide_legend(override.aes = list(shape = NA)))


Created on 2023-02-08 with reprex v2.0.2
Hopefully this approach can be adapted to your use-case.


---

