使用 longCatEDA 在千层面图中个性化颜色
Personalize colors in lasagna plot using longCatEDA
可以使用此代码绘制具有 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.Red
2.Yellow
3.Green
我找不到如何使用特定颜色,所以我尝试了默认调色板,我能做的最好的就是使用“彩虹”方案。
还有 colorspace
和 RColorBrewer
,但其中 none 包括我需要的 3 种颜色(按红色、黄色和绿色的顺序)
不使用 colScheme
参数,而是使用 cols
:
library(longCatEDA)
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, cols = c("red", "yellow", "green"), legendBuffer=0, groupBuffer=0,main='How to personalize colors?')
legend(16.5, 100, legend=lc$Labels, lty=1, col=c("red", "yellow", "green"), lwd=2)
由 reprex package (v2.0.1)
于 2021-08-17 创建
可以使用此代码绘制具有 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.Red
2.Yellow
3.Green
我找不到如何使用特定颜色,所以我尝试了默认调色板,我能做的最好的就是使用“彩虹”方案。
还有 colorspace
和 RColorBrewer
,但其中 none 包括我需要的 3 种颜色(按红色、黄色和绿色的顺序)
不使用 colScheme
参数,而是使用 cols
:
library(longCatEDA)
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, cols = c("red", "yellow", "green"), legendBuffer=0, groupBuffer=0,main='How to personalize colors?')
legend(16.5, 100, legend=lc$Labels, lty=1, col=c("red", "yellow", "green"), lwd=2)
由 reprex package (v2.0.1)
于 2021-08-17 创建