[Traminer-users] Adding value labels to graphs

Florian Hertel fhertel at bigsss.uni-bremen.de
Thu Jul 19 14:44:02 CEST 2012


Dear Joel,

I did it in a relatively exhausting and time consuming way! However, 
this was my solution. I first opened the graphical device , than defined 
with par the number of indexplots and the order (mfrow=c(6,2)), i.e. i 
had two columns containing 6 plots each. Than I defined a vector "pres" 
comprising the names of my plots. I produced the plots using a loop 
(somewhat inefficient for R, I guess). In this loop I am defining the 
title using the "paste"-command as the respective item of the label 
vector "pres" and the number of the people in my cluster ,sum(clus30m 
==j). It is important to not put apostrophs surrounding the latter 
because R should evaluate it and paste in the number and not the string 
"sum(clus30m ==j)". The whole thing is time consuming because you have 
to look and arrange your plots beforehand. However, the result of the 
syntax looks like P.33ff. of this working paper 
http://www.diw.de/documents/publikationen/73/diw_01.c.372555.de/diw_sp0374.pdf. 
I hope this helps.

Here is my syntax:
tiff("seqdplot30_MpraesI.tif", width=230, height=310,
     units = "mm", pointsize = 20, res=300,compression="none"
     )
par(mar=c(2,1,1,1), mfrow=c(6,2))        #mar: margin 
c(bottom,left,top,right)
pres <- c("High Service","Low to High Service","Skilled Manual","Routine 
Service","Petty Bourgeoisie","Low Service",
           "Non-Manual","Unemployed","Unskilled Manual","Unskilled to 
Skilled Manual","Skilled Manual to Low Service","Non-Working")
#Sequence distribution plots
for (j in c(1,6,7,4,5,3,9,8,12,2,11,10)) {
seqdplot(dat30m[clus30m == j, ],withlegend=TRUE, cex.legend=3, 
title=paste(pres[j],", n=",sum(clus30m ==j),sep=""),
          use.layout=FALSE, yaxis=FALSE, border="black", space=0, axes= 
if (j==11 | j==10) ("bottom") else ("FALSE"), xtlab=c(seq(30,44)))
}
dev.off()

I have an additional question. Does anyone know how to get the plots 
shaded or patterned instead of colored. For journals, it makes more 
sense to have a certain state symbolized by a pattern for example 
parallel stripes instead of having it displayed as green. I remember 
that I could not figure out how to do this. I would be very thankfull 
for any experience or info on that, whether a respective package exists 
and whether it works with TraMineR. Again, thanks to all who have 
contributed and contribute to that package!

All the best,
Florian



-- 

Florian Hertel

-- 
Institute of Sociology
Social Science Faculty (FB 8)
University of Bremen

Bremen International Graduate School of Social Sciences (BIGSSS)

-- 
Office:
BIGSSS / University of Bremen
Wiener Straße
28359 Bremen
Germany

phone: ++49.(0)421.218-66419
mail : fhertel at bigsss.uni-bremen.de
web  : www.bigsss-bremen.de/index.php?id=fhertel



Am 19.07.2012 00:38, schrieb Joel Schwartz:
> Is there a way to add value labels to a TraMineR sequence plot? My 
> client would like each rectangular block of a state distribution plot 
> to be labeled with the number of subjects in that block.
>
> If there's no pre-packaged way to do it, is there a way to extract the 
> coordinates and the numbers of subjects in each rectangular block so 
> that I can write a text() function to add the value labels?
>
> One other thing: In experimenting with adding text manually, I noticed 
> that I could only add text to the right third of the plot. The plot 
> area coordinate values seem to run from 0 to 1 on the y-axis and from 
> -10 to 2 on the x-axis. If I used an x-coordinate less than -2, then 
> no text was added to the plot. Do you know why I couldn't add text to 
> the right side? Also, the x-coordinate values seem a bit odd. Why -12 
> to 2 (in jumps of 2) for a graph with a sequence length of 7?
>
> Thanks for your help.
>
> Joel
>
>
>
>
> _______________________________________________
> Traminer-users mailing list
> Traminer-users at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users

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


More information about the Traminer-users mailing list