Colors Not Showing Up in Histogram

I made the following histogram in R:

a = rnorm(100000,60000,1000)
b = a

c = data.frame(a,b)
color <- c("black", "red")     
color_1 <- sample(color, nrow(c), replace=TRUE, prob=c(0.9, 0.1))
c$color_1 = as.factor(color_1)

hist(c$a, col = c$color_1, 100000)


But there are no colors that are showing up. Does anyone know how to fix this?


I think you are asking R to plot too many bins and the border color of the histogram bars is all that you see. Try using

hist(c$a, col = c$color_1, 100000, border = NA)

Even better, plot many fewer bins.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.