Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imputing new axis tick labels using seqrplot command

Tags:

r

traminer

I'm using the R packages TraMineR to compute and analyze state sequences. I'm trying to plot with seqrplot command and to change the x axis tick labels. The code would be, for example:

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))

The x axis disappears but the new axis with the imputed thick values appears somewhere at the very bottom right of the plot. In other words, it doesn't replace the deleted axis. Does anyone know what I'm doing wrong? Thank you

like image 729
emanuela.struffolino Avatar asked Dec 16 '25 17:12

emanuela.struffolino


1 Answers

The problem is that by default seqrplot (as other plot functions of the seq?plot family) automatically displays the color legend together with the plot, and uses layout to organize the plot and the legend in a single graphic. If you want to act on the axes, you should disable the automatic legend by setting withlegend = FALSE, and then display the legend my hand. For example:

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)
like image 53
Gilbert Avatar answered Dec 19 '25 07:12

Gilbert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!