-
Notifications
You must be signed in to change notification settings - Fork 165
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
modify legend text of ggscatter() and label font of stat_cor() #111
Comments
Did you/anyone figure this out? I have the same issue. |
Use geom_point() instead of ggscatter() to address two legends issue. |
kassambara
added a commit
that referenced
this issue
May 8, 2020
Fixed now, thanks! library(ggpubr)
#> Le chargement a nécessité le package : ggplot2
# Reg line without confidence band
ggscatter(
iris, x = 'Sepal.Length', y = 'Petal.Length', color = 'Species',
add = "reg.line", conf.int = FALSE
)+
stat_cor(aes(color = Species, label = paste(..rr.label.., ..p.label.., sep = "~`,`~")), show.legend = FALSE) +
scale_color_discrete(
name = 'Species',
labels = c(expression(italic(h)^2), expression(italic(H)^2), expression(italic(HH)^2))
)
#> `geom_smooth()` using formula 'y ~ x' # Reg line with confidence band
ggscatter(
iris, x = 'Sepal.Length', y = 'Petal.Length', color = 'Species',
add = "reg.line", conf.int = TRUE
)+
stat_cor(aes(color = Species, label = paste(..rr.label.., ..p.label.., sep = "~`,`~")), show.legend = FALSE) +
# setting legend for color (point, line)
scale_color_discrete(
name = 'Species',
labels = c(expression(italic(h)^2), expression(italic(H)^2), expression(italic(HH)^2))
) +
# setting legend for fill (confidence band)
scale_fill_discrete(
name = 'Species',
labels = c(expression(italic(h)^2), expression(italic(H)^2), expression(italic(HH)^2))
)
#> `geom_smooth()` using formula 'y ~ x' Created on 2020-05-08 by the reprex package (v0.3.0.9001) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I use the following code,
ggscatter(herita, x = 'sigma2', y = 'pre.mean', color = 'Group', add = "reg.line", conf.int = FALSE)+
stat_cor(aes(color = Group, label = paste(..rr.label.., ..p.label.., sep = "
"))) +,
scale_color_discrete(name = 'Group',labels = c(expression(italic(h)^2),expression(italic(H)^2)))
I got the plot
How do I removed the original legend and keep the revised? Also, I want to revise italic label to 'R2' and 'P' and modify their font size. I tried code,stat_cor(aes(color = Group,label = paste0(expression(R^2)," = ", ..r.., ", P = ", ..p..))) and font(), but failed. It seems no parameters for these.
The text was updated successfully, but these errors were encountered: