In R, how can I use different colors for each range in my scatterplot? -
i'm trying plot r series of 120 numbers first 40 of 1 type, next 40 items of second type , last 40 items of third type.
right i'm plotting scatter-plot , hard tell 3 sections apart:
data <- read.table("mydata.txt") plot(data[,1])
is there way distinguish 3 sections, in following mockup made?
you provide colour vector if data ordered.
mydata <- runif(120) plot(mydata, col = rep(rainbow(3), each = 40))
rainbow(3)
makes colour vector of 3 colours, , rep
each = 40
makes 40 copies of each.
Comments
Post a Comment