I am working with the R programming language. I simulated some data and made the following plot:
a = rnorm(1000,10,10)
b = rnorm(1000,10,10)
c = rnorm(1000,10, 1)
d = data.frame(a,b,c)
plot(x = d$a, y = d$b, col = d$c)
In the above plot, the points are colored according to the value of "c". Is it possible to add a legend that shows which colors are associated with which values of "c"?
I know how how to do this using the plotly library:
library(plotly)
plot_ly(data = d, type = "scatter", mode = "markers", x = ~a, y = ~ b, color = ~ c)
But is it possible to make this "color gradient legend" using base R?
Thanks