require(ggplot2)
## Loading required package: ggplot2
require(reshape2)
## Loading required package: reshape2
data(iris)
Tr <- ggplot(data = iris, aes(x = Sepal.Width, y = Sepal.Length, 
                              color = Species))
Tr + geom_point() +
        # facet_grid(.~ Species) +
        scale_color_manual(values = c(versicolor = 'red',  setosa ='orange',
                                      virginica = 'blue'))

scale continuous is on continuous data

Tr <- ggplot(data = iris, aes(x = Sepal.Width, y = Sepal.Length, 
                              color = Sepal.Length))

Tr + geom_point() +
        scale_color_continuous(low = 'blue', high = 'red')

Using Melt and themes

head(melt(iris))
## Using Species as id variables
##   Species     variable value
## 1  setosa Sepal.Length   5.1
## 2  setosa Sepal.Length   4.9
## 3  setosa Sepal.Length   4.7
## 4  setosa Sepal.Length   4.6
## 5  setosa Sepal.Length   5.0
## 6  setosa Sepal.Length   5.4
ggplot(data = melt(iris)) + 
        geom_histogram(aes(x = value, fill = variable), binwidth = 0.2) +
        facet_grid(Species ~ variable) + 
        theme_bw() +
        theme(legend.position = 'top', title = element_text(size = 20,
                                                            color = 'orange',
                                                            angle = 23)) +
        theme(axis.text.x = element_text(size = 12, angle = 90, vjust = 0.5))
## Using Species as id variables

write and save your theme

ThorstenTheme <- theme_bw(18) + theme(title = element_text(family = 'Monaco', size = 22),
                       legend.position = 'none')
# you can then save this theme and next time

ggplot(data = melt(iris)) + 
        geom_histogram(aes(x = value, fill = variable), binwidth = 0.2) +
        facet_grid(Species ~ variable) +
        ThorstenTheme
## Using Species as id variables

m <- matrix(rpois(200, 76), ncol = 10)
rownames(m) <- letters[1:20]
colnames(m) <- letters[1:10]

head(melt(m))
##   Var1 Var2 value
## 1    a    a    73
## 2    b    a    89
## 3    c    a    78
## 4    d    a    70
## 5    e    a    60
## 6    f    a    87
ggplot(melt(m)) + geom_bin2d(aes(x = Var1, y = Var2, fill = value))

Grouping is used when you do not use colour or shape, since they imply grouping.

ggplot(iris, aes(x = Petal.Width, y = Petal.Length, colour = Species)) + geom_point( ) + geom_line()