R - Scatterplot

> Procedural Languages > R

1 - About

Advertising

3 - Matrix

  • Useful way to see all plots for a two-class variable
pairs(dataframe,col=dataframe$TwoClassVariable)

4 - Package

4.1 - Graphics

  • Standard scatterplot
plot(data$variable1 ~ data$variable2)
  • Standard scatterplot with regression line
abline(lm(data$variable1 ~ data$variable2), col = "green")
  • Scatterplot matrix
pairs(~data$variable1 + data$variable2 + data$variable3, cex.labels = 1.2)

4.2 - gclus

  • Color scatterplot matrix, colored and ordered by magnitude of r
base <- data[3:8]
base.r <- abs(cor(base))
base.color <- dmat.color(base.r)
base.order <- order.single(base.r) 
cpairs(base, base.order, panel.colors = base.color, gap = .5,
       main = "Variables Ordered and Colored by Correlation")
Advertising

4.3 - rgl

  • Scatterplot in 3D
plot3d(data$variable2, data$variable3, data$variable1, main = "3D Plot")

4.4 - ggplot

Scatterplot:

lang/r/scatterplot.txt · Last modified: 2017/09/14 13:24 by gerardnico