0

I'm plotting with ggplot2; here's the code:

plot <- ggplot(data=data, mapping=aes(x=independent, y=dependent, ecolor=as.factor(subject)))
otlp +
  stat_cor(method = "pearson",  size = 6) +
  geom_smooth(method=lm, se=FALSE, fullrange=TRUE) +
  geom_point(shape=1) +
  labs(color="Subject")

and this is what the legend looks like:

Legend

I'm not sure why the letter "a" is there. When I remove geom_smooth, the line through the "a" goes away which I expected, but I don't know why the letter "a" is not a point with shape=1 like I defined in geom_point. On the graph, the points are correct.

HunterLiu
  • 781
  • 3
  • 6
  • 20
  • 2
    I'm not sure where `stat_cor()` comes from, but it must be plotting text of some kind. The "a" occurs when in ggplot2 with a `geom_text()` layer and color mapping. – aosmith Jun 28 '19 at 19:47
  • 3
    Ah, it's from **ggpubr**. You might need `show.legend = FALSE` in `stat_cor()`, see the documentation for more details. – aosmith Jun 28 '19 at 19:49
  • 3
    Related; [Remove 'a' from legend when using aesthetics and geom_text](https://stackoverflow.com/questions/18337653/remove-a-from-legend-when-using-aesthetics-and-geom-text) (same solution) – Henrik Jun 28 '19 at 19:49
  • that is the default legend key glyph for `geom_text()` - https://github.com/tidyverse/ggplot2/issues/3167. this can be removed as others have mentioned or now customized with `key_glyph = ...` in the `geom` per https://www.tidyverse.org/articles/2019/06/ggplot2-3-2-0/. – Raoul Duke Jul 01 '19 at 17:28

0 Answers0