Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: bar graph axis color- frustrated


From   Fred Wolfe <fwolfe@arthritis-research.org>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: bar graph axis color- frustrated
Date   Fri, 11 Jun 2010 16:50:15 -0500

Thanks to everyone is this thread, and to Nick, David and Scott for
their solutions. It certainly was easy once you know how. I found
Scott's solution easiest for me to use. My final code was:

use raoadotplotdata,clear
local i = 1
foreach var of varlist age - all  {
       local l`var' : var label `var'
       local a " `a' `i' `"`l`var''"' "
       local ++i
}
collapse age-all,  by(type)
stack age-all, into(a) clear
label def _stack `a'
label val _stack _stack
bys _s: gen origin = _n -1
reshape wide a, i(_s) j(origin)
label var a0 "RA"
label var a1 "OA"
graph dot (asis) a* , ylab(.5 [.1] 1) exclude0 schem(bw)
ytit(Concordance coefficient) xsize(4) ysize(5.3)  over(_s)
legend(position(3) ring(0))

Fred

On Fri, Jun 11, 2010 at 12:18 PM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> This information to me supports my earlier suggestion. Given this kind
> of problem my focus would be entirely on creating a results set,
> alongside or independently of your dataset. If you create an axis
> variable running 1,2,3,... and associated text labels, then a helper
> program -labmask- was written up in the Stata Journal which maps values
> to value labels.
>
> A strategy would be
>
> * initialise variables
>
> gen axisorder = _n
>
> gen label = ""
>
> gen num1 = .
> gen num2 = .
>
> local obsno = 1
>
> * loop over possibilities
>
> quietly foreach <loopinfo>  {
>
> replace label = "<text for this situation>" in `obsno'
>
> replace num1 = <result for this situation> in `obsno'
>
> local ++obsno
>
> }
>
> labmask axisorder, val(label)
>
> graphics in terms of axisorder, num1, num2, etc.
>
> I don't see that you need StataCorp to fix the graphics. Conversely, a
> fix general enough to tackle what you want to do would probably result
> in a syntax very difficult to understand.
>
> A limitation of the graph you displayed is that very space is devoted to
> data and that the two sets are difficult to compare precisely.
> Overlaying the graphs seems indicated.
>
> Nick
> n.j.cox@durham.ac.uk
>
> Fred Wolfe
>
> I hope I can explain it it. First, let me say that I think I can
> figure out ways to do this by reorganizing the data. But the time
> involved in doing this is (at least for me) too long.
>
> Consider the example below:
> http://screencast.com/t/NjUwNmE3YTMt
>
> This is a special case of a general problem. Special because in this
> instance it is a results data set that was made by copying results
> from Stata to a new data set.
>
> In this instance, each named line represents a different variable. The
> code for one side of the graph is:
>
>   use raoadotplotdata, clear
>   graph dot (asis) age - all ,ascat ylab(.5 [.1] 1) exclude0
> schem(bw) ytit(Concordance coefficient) xsize(4) ysize(5.3)
> by(type,note(""))
>
> Now, what I would really like to be able to do is to not use "by" and
> have both types of symbols (RA and OA) be displayed on each line. If I
> simply do over(), the groups are placed far apart.
>
> So, in general, I would like a simple way to manage multiple variables
> and to display the by group or over group results on the same line or
> immediately below the same line.
>
> I have looked at stripplot, the manual, and Michael's book to no avail.
>
> It is usually that when I come to conclusions like this there is a
> simple solution that I have overlooked. I hope it is the case now.
>
> On Fri, Jun 11, 2010 at 6:24 AM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
>> Fred has raised similar issues before, but I am still fuzzy about what
>> the precise problem is.
>>
>> Perhaps Fred could expand on the nitty-gritty of his difficulties with
> a
>> small realistic data example or two.
>>
>> My guess is that the right kind of solution might not be a hit to
>> Stata's graphics, but some helper commands that prepare datasets to be
>> fed to the graphics.
>>
>> Nick
>> n.j.cox@durham.ac.uk
>>
>> Fred Wolfe
>>
>> As an aside, both Michael's book and the manual spend much time in
>> graph bar and dot with over(). I usually have multiple variables with
>> overlapping groups. Over() doesn't help. I do wish that Stata might
>> address that very common problem (at least for me).
>
> *
> *   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/
>



-- 
Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
NDB Office  +1 316 263 2125 Ext 0
Research Office +1 316 686 9195
fwolfe@arthritis-research.org

*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index