Announcement

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

  • Subgroups with coefplot allowing each graph to have its own scale and adjust location of legend

    Dear all

    I am using the following code to create a graph with 5 plots:

    Code:
    coefplot  (hba1c1, label(ELSA)) (hba1c2, label(US)) (hba1c3, label(HSE)) (hba1c4, label(Pooled)), bylabel(HbA1c) || (chol1) (chol2) (chol3) (chol4), bylabel(Cholesterol) ///
    || (sysval1) (sysval2) (sysval3) (sysval4), bylabel(Systolic BP) || (pulse1) (pulse2) (pulse3) (pulse4), bylabel(Pulse) ///
    || (wstval1) (wstval2) (wstval3) (wstval4), bylabel(Waist) xline(0) drop(_cons age) ///
     byopts(legend(pos(10))) order(sex white degree income3) msymbol(square) msize(small) scheme(plottig)
    This works well, but the legend is displayed centre middle, and given that there are 5 plots there is an obvious space in the bottom right hand corner than the legend would go.

    The following gets it closer, but it won't actually go in the blank space and instead goes outside the graph region:

    Code:
    coefplot  (hba1c1, label(Survey 1)) (hba1c2, label(Survey 2)) (hba1c3, label(Survey 3)) (hba1c4, label(Pooled)), bylabel(HbA1c) || (chol1) (chol2) (chol3) (chol4), bylabel(Cholesterol) ///
    || (sysval1) (sysval2) (sysval3) (sysval4), bylabel(Systolic BP) || (pulse1) (pulse2) (pulse3) (pulse4), bylabel(Pulse) ///
    || (wstval1) (wstval2) (wstval3) (wstval4), bylabel(Waist) xline(0) drop(_cons age) ///
     byopts(legend(pos(4))) order(sex white degree income3) msymbol(square) msize(small) scheme(plottig)
    An additional problem is that I can't seem to specify the byopts(xrescale) option with the above, which is necessary because the different graphs have different scales.

    Thus my problem is twofold:

    1. How do I position the legend inside the blank space where the sixth graph would be if I had one?
    2. How do I do this alongside maintaining the re-scaling option?

    Any help much appreciated!



  • #2
    Unfortunately, having the command without the data is not very helpful to visually identify what is going on. But you may share graphics in the forum. Please read the FAQ. In short, pictures with the extension .png are the best option.
    Best regards,

    Marcos

    Comment

    Working...
    X