Re: st: advanced (for me that is) graphing

 From moleps <[email protected]> To [email protected] Subject Re: st: advanced (for me that is) graphing Date Wed, 13 Jan 2010 21:39:36 +0100

```I appreciate your efforts. However I did stumble across the solution to my colorcoding problem using -plotmatrix- by Adrian Mander, available using ssc install plotmatrix.

tab agecut Year,matcell(r) matcol(m) matrow(i)

plotmatrix,m(r)

Any easy way to set the col and rownames according to the vectors  m & i above?

I agree that the histogram is more elegant when divided into decades, but for each and every year I believe the color coded graph looks better superimposed with the median.

Regards,

/M

On 13. jan. 2010, at 19.52, Nick Cox wrote:

> Not so on superimposition. If you use -twoway histogram- or -histogram, addplot()- you can certainly superimpose other graphs.
>
> As for resolution, I have three comments.
>
> First, people respond to the questions you ask and can have no idea that your real problem is something different unless you tell them. Your example gave 6 groups and several graph types should work fairly well for that case.
>
> Second, if you want fewer graphs you need to group.
>
> Third, my example with -row(1)- was for an example with 5 groups: with many more groups that would be not be a good idea.
>
> All that said, I'm left in some doubt on what you really want. It seems that you asked how to do a certain graph but now decide that it doesn't look good. There is no simple way to compare 56 subsets.
>
> Nick
> [email protected]
>
> moleps
>
> The histogram command ala Nick Cox is closest to what I want to convey, However since there are 56 years along the x-axis it doesnt look very nice. I could graph by decades, but all my other graphs are on individual years.  Also I´m not able to superimpose other plots on the same graph.
>
> On 13. jan. 2010, at 18.33, Nick Cox wrote:
>
>> There are several other possibilities too. For example, -histogram- itself is much more flexible than is widely known:
>>
>> . sysuse auto
>> (1978 Automobile Data)
>>
>> . histogram mpg, by(rep78, compact row(1)) yla(, ang(h)) width(2) xsc(r(0 11)) freq horizontal
>>
>> Also, check out -tabplot- from SSC.
>>
>> Nick
>> [email protected]
>>
>> Nick Winter
>> ===========
>>
>> Interestingly, the table you include makes a nice "plot" itself,
>> showing, more or less, the distribution by decade.
>>
>> Continuing along that line, and rather differently from what you are
>> asking for, violin plots are another way to show distributions over time
>> (or against anything).  My -vioplot- from SSC will do them.
>>
>> Maarten Buis
>> ============
>>
>> Sounds like a case for Nick Cox's -stripplot-, which you can download from SSC by typing in Stata: -ssc install stripplot-.
>> The help-file contains many examples.
>>
>> Moleps Islon
>> ============
>>
>> I´m trying to create a graph with age on the y axis and time on the x axis (year). So far so good, the problem is that I´d like each year to be represented with the distribution of age on the y axis. I was thinking color coding the number of people within each 10-year category on the y axis, and having the colors with the associated numbers   in the legend. preferably all within a twoway graph so that I could also superimpose the median in the end.
>>>
>>> egen agecut=cut(age),at(0(10)100)
>>>
>>>
>>> gives me this
>>>
>>> tab agecut Ye
>>>
>>> |                               Year
>>>   agecut | 1953-1969  1970-1979  1980-1989  1990-1999  2000-2004  2005-2009 |     Total
>>> -----------+------------------------------------------------------------------+----------
>>>        0 |        23         19         16          7          6          3 |        74
>>>       10 |        32         17          7         11          2          6 |        75
>>>       20 |        43         39         38         17          9          4 |       150
>>>       30 |       110         59         77         66         21         21 |       354
>>>       40 |       213        129        153        177         78         54 |       804
>>>       50 |       444        301        259        273        193        144 |     1,614
>>>       60 |       342        330        427        375        211        215 |     1,900
>>>       70 |        72        104        193        257        149        139 |       914
>>>       80 |         2         13         12         26         33         40 |       126
>>>       90 |         0          1          0          1          0          1 |         3
>>> -----------+------------------------------------------------------------------+----------
>>>    Total |     1,281      1,012      1,182      1,210        702        627 |     6,014
>>>
>>> I cannot get my head around to figuring out how to maintain age on the y-axis and have the frequencies color coded instead of having the frequencies on the y-axis and the age categories in the legend. Any ideas?
>>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```