Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: two-way scatter conneted by id and colored by sex


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: two-way scatter conneted by id and colored by sex
Date   Thu, 21 Nov 2013 13:07:15 +0000

All that said, some variant on


twoway line tTbN scan if sex==1, c(L) || line tTbN scan if sex == 2, c(L)

gets you there with your existing data structure.
Nick
[email protected]


On 21 November 2013 10:28, Nick Cox <[email protected]> wrote:
> Thanks for the explanation.
>
> -linkplot- (SSC) has been partially superseded by later additions to
> -graph twoway-.
>
> In any case see
>
> Cox, N. J. 2009. Paired, parallel, or profile plots for changes,
> correlations, and other comparisons. Stata Journal 9(4): 621-639
>
> http://www.stata-journal.com/sjpdf.html?articlenum=gr0041
>
> for detailed discussion, including of alternative graphs that often work better.
>
> Here is some sample code.
>
> clear
> input  PatNo   sex   scan   tTbN
>     690     1      1   1.28
>     690     1      2   1.41
>     714     1      1   1.28
>     714     1      2   1.23
>     735     1      1    .42
>     735     1      2    .65
>     762     1      1      2
>     762     1      2   1.93
>     792     2      1   1.78
>     792     2      2   1.64
> end
>
> reshape wide tTbN, i(PatNo) j(scan)
>
> gen one = 1
> gen two = 2
>
> twoway pcspike tTbN1 one  tTbN2 two if sex == 1, lc(red) || ///
> pcspike tTbN1 one tTbN2 two if sex == 2, lc(blue) ///
> legend(off) ytitle(tTbN) xla(1 2) xtitle(scan)
>
> Nick
> [email protected]
>
>
> On 21 November 2013 05:45, Lars Folkestad <[email protected]> wrote:
>> Dear Nick and Sergiy
>>
>> Im sorry, to me (sitting and working with the data) what i wanted was obviouse. But seeing only have the Info given to you, to try to help i will elaborate:
>>
>>  On my X axis i would like scan.
>> On my Y axis i would like tTbN.
>>
>> Scc i ment ssc
>> Lineplot was autocorrect for linkplot
>> http://www.stata.com/statalist/archive/2003-07/msg00194.html
>>
>> I am not sure but some patients tend to have lower values tTbN at scan 2 and some tend to have higher. I afraid that connect(direct) does not take this into account and i need the connecting lines to be from PatNo to the same PatNo to show what i said before.
>>
>> Hope this was the information you needed.
>>
>> Mvh Lars Folkestad
>>
>>> Den 21/11/2013 kl. 00.26 skrev "Sergiy Radyakin" <[email protected]>:
>>>
>>> Lars, please invest some more time into formulating the question. If
>>> you just want a connected scatterplot of anything, something like this
>>> should satisfy all of your requirements:
>>>
>>> twoway scatter tTbN PatNo if sex==1 , lc(red) connect(direct) mcolor(red) || ///
>>>       scatter tTbN PatNo if sex==2 , lc(blue) connect(direct) mcolor(blue)
>>>
>>> it is connected, it is split by sex into two colors and ordered by PatNo.
>>> Whether it makes sense or not, I don't know.
>>>
>>> Sergiy.
>>>
>>>> On Wed, Nov 20, 2013 at 3:48 PM, Nick Cox <[email protected]> wrote:
>>>> What do you want on your y axis?
>>>>
>>>> What do you want on your x axis?
>>>>
>>>> What is "scc"?
>>>>
>>>> What is "lineplot"?
>>>>
>>>> More explanations, please?
>>>>
>>>> Nick
>>>> [email protected]
>>>>
>>>>
>>>>> On 20 November 2013 20:26, Lars Folkestad <[email protected]> wrote:
>>>>> Dear Listers
>>>>>
>>>>> Firstly sorry if this is spam, but i just got a mail saying the first one
>>>>> i sent out was spam.
>>>>>
>>>>> I have a data set with the following structure and variables:
>>>>> +---------------------------+
>>>>>     | PatNo   sex   scan   tTbN |
>>>>>     |---------------------------|
>>>>>  1. |   690     1      1   1.28 |
>>>>>  2. |   690     1      2   1.41 |
>>>>>  3. |   714     1      1   1.28 |
>>>>>  4. |   714     1      2   1.23 |
>>>>>  5. |   735     1      1    .42 |
>>>>>     |---------------------------|
>>>>>  6. |   735     1      2    .65 |
>>>>>  7. |   762     1      1      2 |
>>>>>  8. |   762     1      2   1.93 |
>>>>>  9. |   792     2      1   1.78 |
>>>>> 10. |   792     2      2   1.64 |
>>>>>     +---------------------------+
>>>>>
>>>>> I would like to graph a connected scatterplot showing in red lines if
>>>>> sex=1 and blue if sex=2, and i want to connect by PatNo. I've been reading
>>>>> some old FAQ's and found the scc add-on lineplot, but cannot figure out
>>>>> how to get different colored lines by sex.
>>>>>
>>>>> Is there a more 'official' way to get what i want from these data?

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index