Check the dataviz catalog to learn more about histograms. For more examples, see graph #25 and graph #2 !
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# Create data my_variable=rnorm(2000, 0 , 10) # Calculate histogram, but do not draw it my_hist=hist(my_variable , breaks=40 , plot=F) # Color vector my_color= ifelse(my_hist$breaks < -10, rgb(0.2,0.8,0.5,0.5) , ifelse (my_hist$breaks >=10, "purple", rgb(0.2,0.2,0.2,0.2) )) # Final plot plot(my_hist, col=my_color , border=F , main="" , xlab="value of the variable", xlim=c(-40,40) ) |
Not what you are looking for ? Make a new search ![mediatagger]
Leave a Reply
Be the First to Comment!