[R-sig-eco] Line Plot from a subset of a data frame

Patrick Kilduff dpkilduff at yahoo.com
Mon Feb 13 23:53:53 CET 2012


Hi Ben -

Another solution, I hope, using the ggplot2 package:

library(ggplot2)

p = ggplot(acfl, aes(x = DISTANCE, y = Mantel.r) ) + # I renamed the 
variable names when reading in the data
   geom_line(aes(colour = Site.Type)) +
   scale_colour_manual(values = c("red", "blue", "green"), name =  "Site 
Type") +# control plotting colors and legend title
   theme_bw() # +
   # facet_grid(SPECIES ~ Migratory.Status) # undo the last comments to 
see how faceting works

print(p) # print the plot

- Patrick

On 2/13/12 2:01 PM, bpdilla wrote:
> ALL=subset(acfl,acfl$Site.Type=='ALL')
> ##and then##
> plot(ALL$DISTANCE,ALL$Mantel.r,type='o')



More information about the R-sig-ecology mailing list