I have a list of lists that I want to plot each list's distribution. Each distribution should be in a different color. Is there any predefined list of colors in R so that I wouldn't need to write the list of colors myself? (The list might get pretty long and I don't want to check everytime, if the length of list is the same with the data!)
Another issue is with the x- and y-axis limits. How can I put them in a way that covers all the values showing in the plot? (If you run the code bellow, the red line is cut on the right)
What I have written so far is:
dput(degree.l)
list(c(schwab = 0, pnc = 0.0344827586206897, jpm = 0.0862068965517241,
amex = 0.0862068965517241, gs = 0.103448275862069, ms = 0.103448275862069,
bofa = 0.103448275862069, citi = 0.103448275862069, wf = 0.120689655172414,
spgl = 0.120689655172414, brk = 0.137931034482759), c(schwab = 0.0166666666666667,
pnc = 0.05, ms = 0.0666666666666667, spgl = 0.0833333333333333,
jpm = 0.1, bofa = 0.1, wf = 0.1, amex = 0.1, gs = 0.116666666666667,
brk = 0.116666666666667, citi = 0.15), c(schwab = 0.0428571428571429,
gs = 0.0714285714285714, pnc = 0.0714285714285714, citi = 0.0857142857142857,
amex = 0.0857142857142857, spgl = 0.0857142857142857, jpm = 0.1,
brk = 0.1, ms = 0.114285714285714, wf = 0.114285714285714, bofa = 0.128571428571429
))
colors <- c("red","blue")
density.plot <- function(cent.l){
plot(density(cent.l[[1]]), col="orangered")
for(i in 2:length(cent.l)){
lines(density(cent.l[[i]]), col= colors[i-1])
}
}
density.plot(degree.l)