Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary legend problem when applying stat_summary #607

Open
Jihooevelyn opened this issue Jun 12, 2024 · 0 comments
Open

Unnecessary legend problem when applying stat_summary #607

Jihooevelyn opened this issue Jun 12, 2024 · 0 comments

Comments

@Jihooevelyn
Copy link

Hello,

When I draw this graph, there is an unnecessary legend under each plot label "a". When I try to delete this by deleting "color = variable" in the code, it gives the average value of two plots and not for each which is something I need while analyzing the data.

library(data.table)
library(ggplot2)
library(ggpubr)

dt <- as.data.table(mtcars)

dt_selected <- dt[, .(gear, disp, cyl)]

dt_melted <- melt(dt_selected, id.vars = "gear")

p <- ggline(data = dt_melted, x = "gear", y = "value", color = "variable",
            add = "mean_sd") +
  stat_summary(fun = mean, geom = "text", aes(color = variable, label = round(..y.., 2)))

print(p)
Screenshot 2024-06-12 at 1 36 59 PM

Please Help!
Appreciate your help, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant