Skip to main content

Posts

Showing posts from March, 2011

Some -statplot- examples, Part 2 (wrapping long labels)

...continued from  Part 1 ... Part 1 of this post covered some advanced examples of -statplot-, focusing on the use of combinations of over() and by() options. In Part 2 , I examine some strategies to use -statplot- with really long variable and/or value labels.  Recently, I was using -statplot- to create some tables in a paper where some of the labels in the tables needed to be the (longish) question and answer choice text, I discovered how long labels can really be a pain for graphs.  This is a problem for any graph in Stata, regardless of whether your labels are in the legend or at the axis; however, my preference is that long labels (up to a limit) look better at the axis. So, the examples below show how to use -statplot- options to create wrapped labels.  I hope to create an option to help make this a part of -statplot- at some point in the future, but for now, the code below is a good template for helping you to automate wrapping labels.  This can be extended to other plott

Some -statplot- examples

- statplot - (co-authored by Nick Cox and myself) was released earlier this month.  You can get it at the SSC [ 1 ] [ 2 ]. In this posting, I show you some more advanced examples of using -statplot- using the Stata nlsw88 dataset (-sysuse nlsw88.dta-).  [ Note : Click on any of the graphs below to see a larger example in a new tab/window.] First, a basic example of -statplot- might look like: ***********************!begin sysuse nlsw88.dta, clear  statplot grade tenure wage, blabel(bar) subtit({it:-statplot-} example) graph export "fig1.png", as(png) replace ***********************!end Fig. 1 The main advantage of -statplot- is creating plots of summary stats with the labels moved from the legend (the usual placement when using -gr bar|hbar|dot-) to the axis.  So, I could create a graph of the same data above with something like: graph hbar (mean) grade tenure wage however, it would look like the graph on the left in Fig. 2 below, where we still have a legend and an a