Statalist


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

st: changing the legend in twoway function


From   Miranda Kim <mk@mrc.soton.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   st: changing the legend in twoway function
Date   Mon, 10 Aug 2009 10:00:51 +0100

Hi,
Can anyone help me with this?
I am trying to write a program that plots the functions a + bx + cx2 (on the same graph), where a, b and c are stored variables. I want to label the legend with the set of values a, b and c for each graph.
For example if I have:
a   b   c
1   3   4
2   5   8
then I want to have "a=1, b=3, c=4" and "a=2, b=5, c=8" assigned to the relevant graph in the legend. How can I do this? Also , how complicated would it be to control the colours or line types of the graphs?

My current program is as follows:

program define polysameplot

   foreach i of numlist `0' {
local gr "`gr' function y=a[`i']+b[`i']*x+c[`i']*x^2, range(-5 5) ||"
   }
   twoway `gr'

end

polysameplot 38 39 40 41

I use Stata 10.

Thanks a lot for your help!

*
*   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   |   What's new   |   Site index