在此处输入图像说明序列分析的发布中的常见问题1 2或通常具有许多分类状态的图表是它们不容易转移到黑白纸质出版物。有一些工具,如Colorbrewer,可以帮助做出关于灰度颜色的明智决策。但是,如果调色板超过5或更多灰度,则结果不令人满意。因此,在这些情况下将图案填充添加到某些图形区域会非常有用(尽管着名的Edward Tufte不建议这样做。)
是否可以使用R基础图形的图案填充功能或基础图形的扩展来向TraMineR
图形添加填充图案?
以下是序列索引图的小例子:
library(TraMineR)
library(RColorBrewer)
## Load example dataset with 8 sequence states
data(biofam)
## Define sequence objects
biofam.lab <- c("Parent", "Left", "Married", "Left+Marr",
"Child", "Left+Child", "Left+Marr+Child", "Divorced")
biofam.seq <- seqdef(biofam, 10:25, labels=biofam.lab)
## Example plot in colors
seqiplot(biofam.seq, cex.legend=.7)
## Example plot in greys for b/w publication
seqiplot(biofam.seq, cex.legend=.7, cpal=brewer.pal(8, "Greys"))
答案 0 :(得分:1)
在评论之后,我想出了这个“解决方案”,其图形仍然可以改进。不幸的是,我也无法覆盖传说,所以他们仍然需要一些工作。如果有人有想法我会很高兴吗??
## Define smaller black/grey palette, delete almost white tones
greys <- c("black", "black", "black", "black", brewer.pal(5, "Greys")[2:5])
## Example plot using density and overwriting angle options
par(mar=c(1,2,1,1))
layout(matrix(c(1,2), 2, 1, byrow = TRUE), heights=c(2,1))
seqiplot(biofam.seq, withlegend=FALSE,
cpal=greys,
density=c(20, 20, 20, 20, -1, -1, -1, -1),
angle=c(45, 90, 45, 0, 0, 0, 0, 0))
seqiplot(biofam.seq, withlegend=FALSE,
cpal=greys,
density=c(20, 20, 20, 20, -1, -1, -1, -1),
angle=c(45, 90, 135, 0, 0, 0, 0, 0),
add=TRUE)
# Different angle for third state creates grid instead of patterns
seqlegend(biofam.seq, pos="center", ncol=3, fontsize=.7,
cpal=greys,
density=c(20, 20, 20, 20, -1, -1, -1, -1),
angle=c(45, 90, 45, 0, 0, 0, 0, 0))
seqlegend(biofam.seq, pos="center", ncol=3, fontsize=.7,
cpal=greys,
density=c(20, 20, 20, 20, -1, -1, -1, -1),
angle=c(45, 90, 135, 0, 0, 0, 0, 0))
# Draws an additional legend instead of overwriting the first