Make scatter plots for multiple subsets of data

Let me introduce my data-set and my preliminary result first for better understanding my question. my dataset looks like:

Place      Species      Size      Conc.
 A           BT          24        0.2
 A           ST          76        1.4
 ...
 B           BT          45        1.2
 B           ST          21        0.7
 ...

I want to make scatterplot of Size against Conc. for each Species at each Place. What I have done uses ggplot2 to make a graph as below:

scatterplot <- ggplot(mydata, aes(x = Size, y = Conc, color = Species)) + 
  geom_point(shape = 1) 

Though this graph plots by the species group in different color, it summarizes all data in the dataset and fails to plot for different places.

I think the code below

scatterplot <- ggplot(mydata[mydata$place == "A"], aes(x = Size, y = Conc, color = Species)) + geom_point(shape = 1) 

works for plotting just place A and I can do this for different places one by one. However, in my real dataset, the place variable has tons of different places, and I can't type them all out one by one manually. Thus my question actually is how to let R make those plots for different places automatically at one time?

Answers


Try:

 ggplot(ddf)+geom_point(aes(Size, Conc.))+facet_grid(Place~Species)

If there are too many places:

ggplot(ddf)+geom_point(aes(Size, Conc., color=Place))+facet_grid(.~Species)

Or, in one graph:

ggplot(ddf)+geom_point(aes(Size, Conc., color=Place,shape=Species), size=5)


Need Your Help

How do I use command line input to select a properties file to use in a gradle build?

java gradle properties-file

I have a java project that can use one of a few different properties files based on the environment I will build it for (eg. development.properties will give me properties that are good for a devel...

Preventing UI from freezing due to ajax calls

jquery ajax

The commented out code at https://github.com/DjangoCoder/DjangoGUI/blob/master/templates/base.html on lines 192, 193, 196, 197, 199, and 205 was freezing the UI up. I could barely use my text edito...