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]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: plot yline for different values on each sub plot |

Date |
Fri, 15 Apr 2011 10:16:45 +0100 |

I don't know an easy way of doing this. You might try plotting all four lines in all panels and then deleting three you don't need in the Editor. Or you might draw each graph separately and then use -graph combine-. Or you might rewrite using -twoway bar-. Either way, your macro manipulation is not going to work as you intend. Stata interprets your `= ' stuff precisely once and _before_ the -graph- command gets to work. It certainly does not do that separately for each separate graph, and it will always interpret a reference to a variable as a reference to its value in the first observation. Of course, wanting a different yline in each panel is a perfectly reasonable request, but I think you will need to do it in one of the ways mentioned above. Nick On Fri, Apr 15, 2011 at 9:56 AM, Timothy Colbourn <t.colbourn@ich.ucl.ac.uk> wrote: > I have a bar graph plotted 4 times in one for each different arm of the trial I am analysing: by(arm) > > I have ploted a yline showing the expected number of births in each arm: yline(`=expbirths') which is a reference against the observed births bars plotted for each month (x axis). The problem is that Stata plots the yline on each of the 4 sub plots at the same value - the value for the first sub plot (arm) - rather than at the value for each arm on each subplot. I have tried yline(`=expbirths by(arm)') but it does the same thing (with no error message - i.e. it essentially ignores the by(arm). The full syntax for the graph is: > > graph bar (asis) livebirth stillbirth nnd mvital, over(month, label( labsize(vsmall) angle(90))) /// > ylabel(0(50)550, labsize(small) angle(0)) yline(`=expbirths (arm)') ytitle("frequency") /// > by(, title("Births and deaths in each RCT arm", size(small)) note("")) /// > legend(order(1 "Livebirths" 2 "Stillbirths" 3 "Neonatal Deaths" 4 "Maternal Deaths") size(vsmall)) by(arm) > > Is it possible to plot the yline for each value of expbirths on each subplot? * * 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/

**Follow-Ups**:**Re: st: plot yline for different values on each sub plot***From:*Nick Cox <njcoxstata@gmail.com>

**References**:**st: plot yline for different values on each sub plot***From:*Timothy Colbourn <t.colbourn@ich.ucl.ac.uk>

- Prev by Date:
**Re: st: tabplot6 style plot for tableplot?** - Next by Date:
**Re: st: Unique dyads** - Previous by thread:
**st: plot yline for different values on each sub plot** - Next by thread:
**Re: st: plot yline for different values on each sub plot** - Index(es):