简体   繁体   中英

R beanplot change the colour and length of the average line

Consider the following beanplot image in R ...

require(beanplot)
beanplot(USJudgeRatings, 
     side='both', 
     border='NA', 
     col=list('gray','red'),
     ylab='US Judge Ratings',
     what=c(1,1,1,1))

The beanplot helps is says "col ... A vector of up to four colors can be used. In the following order, these colors stand for the area of the beans (without the border, use border for that color), the lines inside the bean, the lines outside the bean, and the average line per bean."

However, I don't understand from the help how to specify the colour of the rug lines and average lines on each bean - guidance would be appreciated (and why does the colour vector have to be defined as a list give the different colours on each side of the paired halves) Is it possible to change the length of the average line?

You need to define col as a list of vectors with 4 colours. Here is an example.

require(beanplot)
beanplot(USJudgeRatings, 
     side='both', 
     border='NA', 
     col=list(c('gray','black',"black","green"),c('red','white',"black","blue"),
              c('#ffffb2','black',"black","#f03b20"),c('#fd8d3c','white',"black","#bd0026")) ,
     ylab='US Judge Ratings',
     what=c(1,1,1,1))

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM