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

Remove the letter 'a' from the legend #106

Closed
atsyplenkov opened this issue Aug 21, 2018 · 7 comments
Closed

Remove the letter 'a' from the legend #106

atsyplenkov opened this issue Aug 21, 2018 · 7 comments

Comments

@atsyplenkov
Copy link

atsyplenkov commented Aug 21, 2018

Hey, I know that there's a bunch of questions at stackoverflow but however I still cannot find a solution.

How can I can remove the letter 'a' from the legend generated by ggscatter? Here is a slightly modified example from ggpubr vignette. I've just added parameters to remove text element from a legend: show.legend.text = F and it's not working!

df <- mtcars
df$name <- rownames(df)
ggscatter(df, x = "wt", y = "mpg",
   color = "cyl", palette = c("#00AFBB", "#E7B800", "#FC4E07"),
   label = "name", repel = TRUE, show.legend.text = F)

rplot

kassambara added a commit that referenced this issue Aug 23, 2018
@kassambara
Copy link
Owner

fixed now, thanks

@jbatovska
Copy link

I know this issue has been closed but I am still having issues with this:

df <- scatter_plot_data
df$Virus <- as.factor(df$Virus)

ggscatter(df, x = "Copies_per_uL", y = "RPKM",
xlab = "Virus copies/uL", ylab = "Viral RPKM",
xscale = "log10", format.xscale = TRUE,
yscale = "log10", format.yscale = TRUE,
add = "reg.line",
color = "Virus", palette = "jco",
shape = "Virus",
show.legend.text = FALSE,
fullrange = TRUE
)+
stat_cor(aes(color = Virus), method = "spearman")

And this is the plot I get:
image

@YinanZheng
Copy link

YinanZheng commented Apr 12, 2019

Same problem here. I have tried the latest release version and the latest github version.

p1 <- ggscatter(all_amish_rmAffected, x = "PAI_1", y = "DNAmGrimAge_clean",
color = "genotype", palette = "jco",
add = "reg.line", conf.int = TRUE)
p1 + stat_cor(aes(color = genotype), label.x = 30)

@piiskop
Copy link

piiskop commented Oct 25, 2022

I confirm that the issue still persists as of 2022:

ggplot(data = current_characteristics_1) + geom_point(aes(x = I, y = U_1)) +                         # 6
  labs(x = TeX("$\\frac{\\textit{I}}{A}$"), y = TeX("$\\frac{\\textit{U}}{V}$")) +
  geom_point(data = current_characteristics_2, aes(x = I, y = U_2)) +
  geom_point(data = current_characteristics_3, aes(x = I, y = U_3)) +
  # guides(color = guide_legend(title = "Alalisvooluallika väljundpinge")) +
  # scale_color_manual(values=rainbow(3)) +
  # scale_color_manual(name='Regression Model',
  #                    breaks=c('10', '12', '14'),
  #                    values=c('10'='pink', '12'='blue', '14'='purple')) 
  # scale_color_discrete(labels = unname(TeX(c("$10 \\cdot V$", "$12 \\cdot V$", "$14 \\cdot V$")))) +
  # stat_regline_equation(aes(x = I, y = U_1, label = paste(..eq.label.., ..rr.label.., ..adj.rr.label.., ..BIC.label.., sep = "~~~~"), colour = "10"), label.y = 5) +
  stat_cor(aes(x = I, y = U_1, colour = "10"), label.y = 5.5) +
  stat_cor(aes(x = I, y = U_2, colour = "12"), label.y = 6)

@WellJoea
Copy link

WellJoea commented Dec 9, 2022

try:
guides(color = guide_legend(override.aes = list(size = 5)))

@kassambara
Copy link
Owner

Please, consider specifying the option show.legend = FALSE when calling stat_cor() as below

suppressPackageStartupMessages(library(ggpubr))

df <- mtcars
df$name <- rownames(df)
df$cyl <- as.factor(df$cyl)


ggscatter(df, x = "wt", y = "mpg",
          color = "cyl", palette = c("#00AFBB", "#E7B800", "#FC4E07"),
          label = "name", repel = TRUE, show.legend.text = FALSE) +
  stat_cor(aes(color = cyl), method = "spearman", label.x = 4, show.legend = FALSE)

@piiskop
Copy link

piiskop commented Dec 9, 2022

@WellJoea, your suggestion does not change a thing. Have you tried it? What is even the purpose of limiting a list size? A hack instead of a real solution?

@kassambra, your suggestion works kind of. It forbids displaying a legend. This is not a solution. i want a legend. Without these irrelevant a's. Can you make it work without any hacks? Like, real programmers, do they consider all the possible options if a new thing is about to be developed. i am so depressed because of poor software. It is regulated in society that poor houses are not allowed. Unfortunately, poor software is. It does not matter that you did it for free. we all do. i do not want even to imagine producing a poor piece of software. What i publish is fully tested. i expect the same from you. From everyone. Quality matters.

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

6 participants