I have very specific ranges I would like to plot in different colors on the same plot using the plot function in R.
The ranges are in a matrix that looks like this:
x
[,1] [,2]
[1,] 0 600
[2,] 700 900
[3,] 950 1000
[4,] 1200 1400
I have a data frame that looks like this:
head(df)
V1 V2 V3 V4 V5 V6
1 0 -280 -93 3 x x
2 1 -279 -93 2 y y
3 2 -278 -93 1 z z
I would like plot column V2 and I would like 5 different colors in the plot: 1 color for position df$V2 0-600, 1 color for 700-900, 1 color for 950-1000, and one color for 1200-1400, and another color for everything else that is not in those ranges (black for example).
I have other matrices that have different sizes, so ideally the code can be used for different amounts of ranges.