【发布时间】:2021-08-17 06:55:54
【问题描述】:
可以使用此代码绘制具有 3 个分类变量的千层面图并且工作正常
[![library(longCatEDA)
library(colorspace)
library(RColorBrewer)
set.seed(642531)
y <- matrix(sample(1:3, 500, replace=TRUE), 100, 5)
set.seed(963854)
times <- matrix(runif(600, 1, 3), 100, 6)
# times must be cumulative
times <- t(apply(times, 1, cumsum))
lc <- longCat(y, times=times)
par(mfrow=c(1,1), bg='white', mar=c(5.1, 4.1, 4.1, 10.1), xpd=TRUE)
cols <- longCatPlot(lc, colScheme='rainbow', legendBuffer=0, groupBuffer=0,main='How to personalize colors?')
legend(16.5, 100, legend=lc$Labels, lty=1, col=cols, lwd=2)][1]][1]
但我正在尝试个性化颜色:
1.红色
2.黄色
3.绿色
我找不到如何使用特定颜色,所以我尝试了默认调色板,我能做的最好的就是使用“彩虹”方案。
还有colorspace和RColorBrewer,但没有一个包括我需要的3种颜色(按顺序红、黄、绿)
【问题讨论】:
标签: r plot categorical-data longitudinal