I need to plot line with discrete color for each segment component give the following data frame:
head(profilo1, 10)
dx TPI DEM
1 0 5 2159.219
2 2 5 2157.735
3 4 5 2156.269
4 6 5 2154.752
5 8 5 2153.282
6 10 5 2151.925
7 12 5 2150.660
8 14 3 2149.402
9 16 3 2148.277
10 18 2 2147.149
dx
& DEM
are x and y, while TPI
is the color attribute (span from 1:10) I need to link to color. I wish to use some color table from RColorBrewer
(eg. Paired).
While I'm looking around for solution, I find useful this
color_paired = brewer.pal(n = 10, "Paired")
plot(profilo1$dx, profilo1$DEM,t='p',
xlab = "Profile distance (m)",
ylab = "Elevation (m.s.l.m)",
col = color_paired[profilo1$TPI], cex= .3)
But I'll prefer line to point.