R histogram - too many variables

I am trying to illustrate a histogram of 33 different variables. Due to the number of variables, I think that β€œnext to” with different colors I need to clearly identify each bar, even using the arrow, if feasible.

I was interested 1) How can I define 33 different colors in R 2) How can I mark them, say, vertically below the X axis with a certain distance from each other, to make my figure more clear.

I use the multhist function from the Plotrix package, and for the data you can only draw 33 random vectors with different lengths!

thanks

-1
source share
2 answers

You can define colors in R in any number of ways; try ?rainbow or ?greyscale for some suggestions

You can also see all the colors here and just create a vector of the desired colors that you call inside your chart function.

Your problem is that the human eye and the printing process cannot distinguish and reproduce many different colors. See the documentation on the colorbrewer website (and color suggestions) for more information.

Not sure what I understand what you are trying to do with labels, but you can re-mark the axis with a call to the axis. See the documentation in ?axis .

+2
source

As Chris said, trying to distinguish 33 colors doesn't work for people. You need to find another type of graph that is not dependent only on color.

Without a reproducible example, it is impossible to say what the plot should be, but here are some general color tips.

Use HCL colors, not RGB or HSV. Read Achim Zeileis RGBland Hiding for an explanation. There are several useful features for creating palettes in the colorspace package.

If your variables are disordered categories (i.e., encoded as factors), then your colors should have different hues. (Use rainbow_hcl .)

If your variables are in some order (ranges or ordered factors), then your colors should have different lightness or color. (Use sequential_hcl .) The difference is that they differ from each other at some midpoint, in which case you need diverge_hcl .

+6
source

Source: https://habr.com/ru/post/919134/


All Articles