Данные
d = structure(list(lx = c(6L, 6L, 16L, 4L),
rx = c(58.340712, -66.993792, -7.163176, 43.801029),
mc = c(6L, 0L, 1L, 2L)),
class = "data.frame",
row.names = c(NA, -4L))
База
#Figure out how many colors you need. If the minimum is 0, we need to add 1
#because indexing in R begins at 1.
n = max(d$mc) + (min(d$mc) == 0)
#Generate n colors based on your preference
cols = colorRampPalette(c("black", "red"))(n)
#Subset colors from 'cols' using values in d$mc
plot(d$lx, d$rx, col = cols[d$mc + (min(d$mc) == 0)], pch = as.character(d$mc), cex = 3)
![enter image description here](https://i.stack.imgur.com/qziSE.png)
гглот
library(ggplot2)
ggplot(d, aes(lx, rx, col = mc)) +
geom_point(size = 3) +
scale_color_gradient(low = "black", high = "red")
![enter image description here](https://i.stack.imgur.com/p6iFk.png)