Announcement

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

  • Problem with 'clockposstyle' for legend in plot with subgraphs in Stata 18

    Hi all,

    I am an experienced Stata user for many years, and I have made a lot of use of the Statalist throughout the years as a reader. This is my first question, though! So thanks for having me.

    After having saved estimates for eight models, I had written the following code for a coefficient plot in Stata 17 using the coefplot command:
    coefplot est1 est2 est3 est4, bylabel(left-panel) ///
    || est5 est6 est7 est8, bylabel(right-panel) ///
    ||, keep(var1) legend(position(6) rows(1))
    This produced a working plot with the legend at the bottom of the plot.

    However, having installed Stata 18, the "legend(position(6))" option does not work. That is, the legend is always placed on the right-hand side of the plot (i.e., clockpos = 3). The "rows(1)" part does work (i.e., if I change the no. of rows to 2, the legend has two rows).

    Also if I use coefplot to plot a single graph, the "legend(position(6))" option works well. E.g., if I do this:
    coefplot est1 est2 est3 est4, keep(var1) legend(position(6) rows(1))
    Does anyone know what is going on? Am I using the coefplot in the wrong way now?

    Thanks, much appreciated!

    Maurits

  • #2
    No data example, but you probably need the legend within the option -byopts()- with by-graphs. coefplot is from SSC (FAQ Advice #12).

    Comment


    • #3
      Thanks for your help, Andrew.

      So I played around and in Stata 18 you need the -byopts()- option to get the position of the legend right. This worked!

      But ... then the rows(#) option does not work. However, the following work around worked:

      coefplot est1 est2 est3 est4, bylabel(left-panel) ///
      || est5 est6 est7 est8, bylabel(right-panel) ///
      ||, keep(var1) byopts(legend(position(6))) legend(rows(1))


      I can't figure out why this is. Does coefplot come pre-installed in Stata 18? I can't remember using ssc install for coefplot for my Stata 18 version. Perhaps the root of the problem lies there?

      All the best,

      Maurits

      Comment


      • #4
        coefplot was and remains community-contributed, written by Ben Jann, published in 2014 and 2015 in the Stata Journal and updated since on SSC.

        If it's on your machine, you must have installed it.

        Code:
        which coefplot, all
        tells you where the files are sitting on your system, and you can compare with what is on SSC through

        Code:
        ssc desc coefplot
        Last edited by Nick Cox; 08 Dec 2023, 03:47.

        Comment


        • #5
          Right, must've kept the .ado files installed while installing Stata 18. Thanks for clarifying!

          Can you explain why my code stopped working in Stata 18 and why I need the workaround? Thanks!

          Comment

          Working...
          X