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: legends after sts graph and addplot


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: legends after sts graph and addplot
Date   Sun, 6 Feb 2011 17:34:14 +0000

Correct. You are getting  exacly you asked for. From Stata's point  of
view, you are asking for -sts graph-; then adding something through
-addplot()-; and then insisting that only two variables are explained
in the legend. So in your code the -legend()- option is acting to
overwrite whatever the -addplot()- would have added to the legend.

Very likely your fix is to insert something like

label(3 "something appropriate")

in the -legend()- option.

In terms of your last question, I think you need to save the -sts
graph- results and plot them afresh in a new -twoway- graph.

Nick

On Sun, Feb 6, 2011 at 2:52 PM,  <[email protected]> wrote:

> Stata seems to ignore legend options when addplot is used after sts graph
>
> The code:
>
> sts graph if hivstatus==1 & artavail==0, surv tmax(60) xlabel(0(5)60, valuelabel) xtitle(age) ///
>        addplot(line weibsurv _t if _t<60, sort)        legend(label(1 "observed") label(2 "fitted"))
>
> produces exactly the same graph as
>
> sts graph if hivstatus==1 & artavail==0, surv tmax(60) xlabel(0(5)60, valuelabel) xtitle(age) ///
>        addplot(line weibsurv _t if _t<60, sort)
>
> There are limits to what I can achieve using variable names for the added curves if I want to add more lines, such as confidence bounds on the fitted curve
>
> Also, is there any way to tell stata to plot the addplot lines BEFORE the sts graph, so that the observed kaplan-meier survival curve appears as the topmost graph?
>

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index