[Traminer-users] Adding value labels to graphs
Joel Schwartz
joel at joelschwartz.com
Thu Jul 19 18:03:26 CEST 2012
Hi Florian,
Thanks for your suggestion. Your code places a custom title at the top of each individual plot. I'm actually trying to do something different. I want to add on the plot itself the number of subjects within each subcategory of each bar. For example, looking at page 33 of your paper, let's take the graph in the top left ("OD25 (n=87)") as an example. I want to put a number inside each gray rectangle and inside each blue rectangle equal to the number of subjects represented by each of those rectangles (the other rectangles in your plot are too thin to do this, but in my case I have enough room to add numbers to nearly all the sub-categories of my plot).
This webpage will give you an idea of what I'm looking for. It's a different type of plot, but it has value labels inside each section of each bar:
http://kimura.no-ip.org/dokuwiki/lib/exe/fetch.php?media=statistics:stacked-barchart.png
Do you know if that's possible in TraMineR?
Thanks again,
Joel
On Jul 19, 2012, at 5:44 AM, Florian Hertel wrote:
> 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
>
> _______________________________________________
> 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/095efe4f/attachment.html>
More information about the Traminer-users
mailing list