Wednesday, 21 August 2013

How to create a scatter plot in R

How to create a scatter plot in R

DataHex <- data.frame(x$codes)
DataHexStd <- data.frame(scale(DataHex))
DataHexStd$x <- rep(1:4, 6)
DataHexStd$y <- rep(1:6, rep(4, 6))
ggplot(DataHexStd, aes(x, y, col = DataHexStd[, 24])) +
scale_colour_gradientn(colours = rainbow(9))+
geom_point(size =20, shape =20) +
theme(legend.position = "none")
x$codes is a SOM output . I used the ggplot to categorized the codes by 9
kinds of colors.
x$codes have 24 rows.each rows correspond to a color.
A matrix
11 12 22
3 5 7
12 2 1
the numbers corresponded to the 24 blocks's colors. in this case , the
pixels of scatter plot is 3*3 and how to put the corresponding colors to
this scatter plot.

No comments:

Post a Comment