使用seqrplot命令输入新的轴刻度标签

时间:2013-07-25 09:54:39

标签: r traminer

我正在使用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轴消失,但带有插补厚值的新轴出现在图的最右下方某处。换句话说,它不会替换已删除的轴。有谁知道我做错了什么? 谢谢

1 个答案:

答案 0 :(得分: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)