开发者

R histogram - too many variables

I am trying to illustrate a histogram of 33 different variables. Due to the number of variables I think "beside" different Colors I need to label each bar in a clear way, even using an arrow, if its doable.

I was wondering about 1) How can I define 33 distinct color in R 2) How can I label them, say vertical below X axis with a certain distance fr开发者_运维问答om each other to make my figure more clear.

I am using multhist function from Plotrix package, and for data you can image just 33 random vector with different length !

Thanks


As Chris mentioned, trying to distinguish 33 colours doesn't work for humans. You need to find a different plot type that doesn't rely on only colour.

Without a reproducible example, it is not possible to say what this plot should be, but here's some generic colour advice.

Use HCL colours rather the RGB or HSV. Read Escaping RGBland by Achim Zeileis for an explanation. There are some useful functions for generating palettes in the colorspace package.

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

If your variables are in some sort of order (ranges or ordered factors) then your colours should have different lightness or chroma. (Use sequential_hcl.) A variation on this is if they differ about some midpoint, in which case you need diverge_hcl.


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

You could also look at all the colors here and just create a vector of your desired colors that you call inside your plot function.

Your problem though is that the human eye and the printing process has trouble distinguishing and reproducing that many distinct colors. See the documentation at the colorbrewer site for more information (and advice on picking colors).

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜