[R] Changing legend to fill colour in ggplot
John Kane
jrkrideau at inbox.com
Fri Jun 28 15:09:57 CEST 2013
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
While the str() data is useful it is much better to provide real sample data. Use dput() to supply it.
If it is a large file send a sample head(dput(df, "somenumber)) with somenumber just enough to provide a representative sample.
We currrently have no idea of what the graph looks like as the R-help list strips that out .With the actual data a reader can just copy it and your code into R and see exactly what you are getting.
Please don't post in HTML. Plain text is much easier to read, the HTML gets dropped and any formating goes to pot.
I think the actual answer is probably straight forward but we really should have the data
Thanks
John Kane
Kingston ON Canada
> -----Original Message-----
> From: suparna.mitra.sm at gmail.com
> Sent: Fri, 28 Jun 2013 13:25:59 +0800
> To: r-help at r-project.org
> Subject: [R] Changing legend to fill colour in ggplot
>
> Hello R experts,
> I am having a problem to edit legend in ggplot using four variables.
>
> My data structure is :
> str(df)
> 'data.frame': 10 obs. of 6 variables:
> $ id : Factor w/ 2 levels "639A","640": 1 1 1 1 1
> 2
> 2 2 2 2
> $ species : Factor w/ 5 levels "acinetobacter_sp",..:
> 2
> 5 1 4 3 2 5 1 4 3
> $ genome_coverage_bp : int 8196 3405 8625 22568 2128 6100 1841
> 3914 8487 1064
> $ genome_length : int 3571237 2541445 3912725 3479613
> 5460977
> 3571237 2541445 3912725 3479613 5460977
> $ genome_coverage_percentage: Factor w/ 10 levels "0.02%","0.04%",..: 8
> 5
> 7 10 2 6 3 4 9 1
> $ avg_depth_coverage : num 121.96 2.81 19.84 399.63 1.64 ...
>
>
> Now what I did is
> p=ggplot(df,aes(genome_coverage_percentage,avg_depth_coverage))+geom_point(aes(colour
> = species,shape = factor(id)))
> p+scale_shape_discrete(name ="",labels=c("Patient 1", "Patient 2"))
> That creats the plot below.
> But I want to change the circles of legend in fill colour. So that it
> doesn't look like it is only from Patient 1, as that also has circle.
> Can anybody help me please?
>
> Thanks a lot in advance :)
> Mitra
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
More information about the R-help
mailing list