3

我正在使用 R 包 TraMineR 来计算和分析状态序列。我正在尝试使用seqrplot命令进行绘图并更改 x 轴刻度标签。代码将是,例如:

library("TraMineR")
data("mvad")
mvad.alphab <- c("employment", "FE", "HE", "joblessness", "school", "training")
mvad.seq <- seqdef(mvad, 17:86, xtstep = 6, alphabet = mvad.alphab)
mvad.dist<-seqdist(mvad.seq, method="DHD")

seqrplot(mvad.seq, dist.matrix = mvad.dist,
         criterion = "density", nrep = 1, title = "End CS qualification",
         border = NA, axes=FALSE)
axis(1, at = c(1, 6, 12, 18, 24, 30, 36, 42, 48, 54,60,66,70), 
     labels = c(1, 6, 12, 18, 24, 30, 36, 42, 48, 54,60,66,70))

x 轴消失,但具有估算粗值的新轴出现在图的右下角某处。换句话说,它不会替换已删除的轴。有谁知道我做错了什么?谢谢

4

1 回答 1

4

问题是默认情况下seqrplot(作为该seq?plot系列的其他绘图功能)会自动将颜色图例与绘图一起显示,并用于layout将绘图和图例组织在一个图形中。如果要对轴进行操作,则应通过设置禁用自动图例withlegend = FALSE,然后将图例显示为我的手。例如:

opar <- par(mfrow=c(1,2))
seqrplot(mvad.seq, dist.matrix = mvad.dist,
         criterion = "density", nrep = 1, title = "End CS qualification",
         border = NA, axes=FALSE, withlegend=F)
axis(1, at = c(1, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 70), 
     labels = c(1, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 70))
seqlegend(mvad.seq)
par(opar)
于 2013-07-25T15:01:30.760 回答