I know it was already answered here, but only for ggplot2 histogram. Let's say I have the following code to generate a histogram with red bars and blue bars, same number of each (six red and six blue):
set.seed(69)
hist(rnorm(500), col = c(rep("red", 6), rep("blue", 7)), breaks = 10)
I have the following image as output:
I would like to automate the entire process, how can I use values from any x-axis and set a condition to color the histogram bars (with two or more colors) using the hist()
function, without have to specify the number os repetitions of each color?
Assistance most appreciated.