[Traminer-users] remove titles from subplots

Reynolds, Jeremy E reyno113 at purdue.edu
Tue Dec 13 15:01:15 CET 2016


Hi All,

Just in case someone else is also interested in removing titles from subplots, I found that the par function can be used to hide the titles by making them white so they blend into the background (see below).  It would be better to remove them entirely, but changing the color seems to work ok.

Jeremy

library(TraMineR)
library(WeightedCluster)
data(mvad)
mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school", "training")
mvad.labels <- c("Employment", "Further Education", "Higher Education", "Joblessness", "School", "Training")
mvad.scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
mvadseq <- seqdef(mvad[, 17:86], alphabet = mvad.alphabet, states = mvad.scodes, labels = mvad.labels, weights = mvad$weight, xtstep = 6)

#Defining the custom cost matrix
subm.custom <- matrix(
  c(0, 1, 1, 2, 1, 1,
    1, 0, 1, 2, 1, 2,
    1, 1, 0, 3, 1, 2,
    2, 2, 3, 0, 3, 1,
    1, 1, 1, 3, 0, 2,
    1, 2, 2, 1, 2, 0),
  nrow = 6, ncol = 6, byrow = TRUE)

mvaddist1.0 <- seqdist(mvadseq, method = "OM", indel = 1.0, sm = subm.custom)
pamclust1.0 <- wcKMedRange(mvaddist1.0, kvals = 2:10, weights = mvad$weight)

par(col.main="white")
seqdplot(mvadseq, group = pamclust1.0$clustering$cluster4, border=NA)



From: traminer-users-bounces at lists.r-forge.r-project.org [mailto:traminer-users-bounces at lists.r-forge.r-project.org] On Behalf Of Matthias Studer
Sent: Thursday, December 1, 2016 3:03 AM
To: Users questions <traminer-users at lists.r-forge.r-project.org>
Subject: Re: [Traminer-users] remove titles from subplots

Hi,

This cannot be done using the group argument. You will need to do the plotting separately for each category. For instance, if you want to group according to the gcse5eq covariate which has two levels:

Group <- factor(mvad$gcse5eq)

par(mfrow=c(nlevels(Group),1)) ##Layout of the plots
for(ll in levels(Group)){ ## The plots are done in the same order as levels()
seqdplot(mvadseq[Group==ll, ], with.legend=FALSE, use.layout=FALSE)
}

Hope this helsp,
Matthias

De : traminer-users-bounces at lists.r-forge.r-project.org<mailto:traminer-users-bounces at lists.r-forge.r-project.org> [mailto:traminer-users-bounces at lists.r-forge.r-project.org] De la part de Reynolds, Jeremy E
Envoyé : mercredi 30 novembre 2016 16:52
À : Users questions <traminer-users at lists.r-forge.r-project.org<mailto:traminer-users at lists.r-forge.r-project.org>>
Objet : [Traminer-users] remove titles from subplots

Hi,

Does anyone know how to remove the subtitles from the subplots that are created with the group option in the seqdplot command?  I didn't see any mention of them in the par help file.  Perhaps I have to do this by somehow removing the labels from the grouping variable?  I have pasted code for an example graph below.

Thanks,

Jeremy


library(TraMineR)
library(WeightedCluster)
data(mvad)
mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school", "training")
mvad.labels <- c("Employment", "Further Education", "Higher Education", "Joblessness", "School", "Training")
mvad.scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
mvadseq <- seqdef(mvad[, 17:86], alphabet = mvad.alphabet, states = mvad.scodes, labels = mvad.labels, weights = mvad$weight, xtstep = 6)

#Defining the custom cost matrix
subm.custom <- matrix(
  c(0, 1, 1, 2, 1, 1,
    1, 0, 1, 2, 1, 2,
    1, 1, 0, 3, 1, 2,
    2, 2, 3, 0, 3, 1,
    1, 1, 1, 3, 0, 2,
    1, 2, 2, 1, 2, 0),
  nrow = 6, ncol = 6, byrow = TRUE)

mvaddist1.0 <- seqdist(mvadseq, method = "OM", indel = 1.0, sm = subm.custom)
pamclust1.0 <- wcKMedRange(mvaddist1.0, kvals = 2:10, weights = mvad$weight)

seqdplot(mvadseq, group = pamclust1.0$clustering$cluster4, border=NA)



Dr. Jeremy Reynolds
Professor
309 Stone Hall
Department of Sociology
700 W. State Street
Purdue University
West Lafayette, IN 47907
Phone: (765) 496-3348
https://www.cla.purdue.edu/sociology/directory/index.aspx?p=Jeremy_Reynolds

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/traminer-users/attachments/20161213/ba018fdf/attachment.html>


More information about the Traminer-users mailing list