2

在此处输入图像描述在发布序列分析或通常具有许多分类状态的图时,常见问题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"))

彩色序列索引图 用于黑白出版的未调整灰色序列索引图

4

1 回答 1

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

在此处输入图像描述

于 2015-03-02T15:58:43.037 回答