Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • aaplot and addplot option

    Hi all,

    I just started using aaplot (from SSC) in Stata 12.1. I am playing around with the addplot option. My ultimate goal is to put a fitted line regression output onto a two-way scatter graph I had previously made (which has axis labels and other features the way I want them). But, when I use the addplot option, I get the error that my save graph is not a two-way graph type. Why do I get the error?

    Here is what I am typing.
    graph twoway scatter y x1 if total>2 & area~=.
    ytitle(, size(medium)) ytitle(test) xtitle(test2) ///
    xtitle(, size(medium)) xlabel(,labsize(medium) ///
    ) title(Panel E) title(, size(medium)) ///
    subtitle(Average test) subtitle(, size(medium)) ///
    graphregion(color(white)) legend(off)
    , saving(graph2.gph)

    aaplot y x1, addplot(graph2.gph)

    Perhaps there is another way to do what I am trying to do. I am happy to format the aaplot, and just use that, but I would like to see if I can get this approach to work before I try to figure out aaplot formatting.

    Thanks,
    Steve


  • #2
    The error message comes from twoway, not aaplot. aaplot calls up twoway to do all the hard work. The addplot() option requires you to give a twoway command, not a graph name or file. The aaplot help file includes a clickable link to the help for addplot(), which does explain and exemplify this use of commands.

    This would be legal with your data as an example of the use of addplot().

    Code:
    aaplot y x1, addplot(scatter y x1 if total>2 & area~=.)
    I don't have a very clear picture of your goal, so I can't easily advise on whether all of what you want to do can be achieved with aaplot.

    Please note our strong preference for use of full real names as identifiers.
    Last edited by Nick Cox; 01 Sep 2014, 15:42.

    Comment


    • #3
      Okay, I suppose I misunderstood the addplot help file. What you are saying makes more sense. What I am trying to do is just add the equation for the lfit line to my formatted graph. Actually, I start to get there with

      aaplot y x1 if total>2 & area~=.
      ytitle(, size(medium)) ytitle(test) xtitle(test2) ///
      xtitle(, size(medium)) xlabel(,labsize(medium)) ///
      graphregion(color(white)) legend(off) ///
      , saving(graph2.gph)

      But adding

      title(Panel E) title(, size(medium)) ///
      subtitle(Average test) subtitle(, size(medium))

      causes the equation to go away. Do you have a suggestion for changing the location of the equation?

      Thanks,
      Steve


      Comment


      • #4
        As is documented in its help file the subtitle is used in aaplot to show the regression equation. Changing its location won't change that. But you have in your case other options available to show what you want e.g. caption(), t1title(), t2title(), etc., and you can change their positions away from their defaults.

        Comment


        • #5
          Excellent, this is helpful. I see that I still have control over the size of the subtitle equation, and other formatting for that. I am glad I found aaplot!

          Comment

          Working...
          X