本文介绍了在beanplot的多种颜色在R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用以下
beanplot(windA, side='both', border='NA',
col=list('gray',c('red','white')),
ylab='Wind Speed (m/s)' ,what=c(1,1,1,0),xaxt ='n')
axis(1,at=c(1:12),labels =c ('Jan','Feb','Mar','apr','may','Jun','Jul','Aug','Sep','Oct','Nov','Dec'))
legend('topright', fill=c('gray','red'), legend= c('Measured', 'calc'))
,我得到以下图片
有没有办法替换颜色?例如,我可以让Jan变成灰色而红色,然后再变成Feb,变成灰色和蓝色,并继续这一年的交替配色方案?
Is there a way that I can alternate the colors? For example, can I get Jan to be gray and red then Feb to be gray and blue and continue this alternating color scheme for the year?
推荐答案
您可以使用示例指定所需的颜色顺序, col = list('gray','red','gray','blue')
数据集 USArrests
从基础 R
,颜色循环,直到绘制所有点。
you could specify the color order you want, col=list('gray','red','grey','blue')
, using a sample dataset USArrests
from base R
, the colors are cycled till all the points are plotted
require(beanplot)
beanplot(USJudgeRatings, side='both', border='NA',
col=list('gray','red','grey','blue'),
ylab='US Judge Ratings' ,what=c(1,1,1,0),xaxt ='n')
这篇关于在beanplot的多种颜色在R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!