[R] legend and values do not match in ggplot
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Fri Aug 4 16:16:18 CEST 2017
Not possible to debug your specific problem without sample data [1][2][3], but learning how to setup and manage factors is a key skill for getting this right.
You will also make it less likely that the email you send gets damaged in transit if you send plain text email instead of HTML.
[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
[2] http://adv-r.had.co.nz/Reproducibility.html
[3] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette)
--
Sent from my phone. Please excuse my brevity.
On August 4, 2017 6:52:56 AM PDT, greg holly <mak.hholly at gmail.com> wrote:
>I have following codes for ggplots. The legends are given in the plot
>do
>not match with the values specified in the codes given below. Your
>helps
>highly appreciated.
>
>Greg
>
> library(ggplot2)
> p <- ggplot(a,aes(x=NO_BMI_FI_beta ,y=FI_beta ,color= Super.Pathway))+
> theme_bw() +theme(panel.border=element_blank()) +
> geom_point(size=3)
> p2<-p+scale_color_manual(name="Super.Pathway",
>labels=c("Amino Acid", "Cofactors and Vitamins", "Carbohydrate",
>"Energy",
>"Lipid", "Peptide", "Nucleotide"),
> values=c("Amino Acid"="red",
> "Cofactors and Vitamins"="purple",
> "Carbohydrate"="darkgreen",
> "Energy"="orange",
> "Lipid"="darkblue",
> "Peptide"="darkred",
> "Nucleotide"="blue"))
> p2
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list