Setting up a new palette() in R: need to call palette(rainbow(N)) twice -
i drawing plots within loop, , every plot needs new palette according number of elements in plot.
i'm puzzled fact palette(rainbow(i)) not have immediate effect. instead, have call twice.
for instance, not work:
for(i in 10:20){ colors <- palette(rainbow(i)) if (i !=length(colors)){cat("\nnumber of colors not match", i,"-", length(colors))} } number of colors not match 10 - 20 number of colors not match 11 - 10 number of colors not match 12 - 11 number of colors not match 13 - 12 number of colors not match 14 - 13 number of colors not match 15 - 14 number of colors not match 16 - 15 number of colors not match 17 - 16 number of colors not match 18 - 17 number of colors not match 19 - 18 number of colors not match 20 - 19 to make sure set new palette, have call twice:
for(i in 10:20){ colors <- palette(rainbow(i)) colors <- palette(rainbow(i)) if (i !=length(colors)){cat("\nnumber of colors un match", i,"-", length(colors))} } is bug or i'm using palette in wrong way?
Comments
Post a Comment