Announcement

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

  • Altering individual boxplots in forestplot

    Hello,

    I am trying to make a forest plot on prevalence rates. This led me to the following command:
    metaprop Ndel Npart, ftt random label(namevar=Study) power(2) by(Setting) nooverall nowt nosubgroup lcols(Study Country Population) texts(170) title("Forest plot point prevalence", size(3.5) box bexpand) astext(50) ciopt(lwidth(vthin) lcolor(dknavy)) pointopt(msymbol(diamond) mcolor(dknavy) msize(vsmall)) boxopt(msymbol(i))

    I am almost there. But I would like to alter the shape of the diamonds of some of the boxes (a few per group).
    Could you possibly help me out?
    Thank you for your time and help.

    From Karin

  • #2
    Dear Karin,
    Is there any chance you could share (part of) your data -- or some alternative data which clearly demonstrates the changes you wish to make?
    Please also note that metaprop is an old command, and is now replaced by metan (current version v4.06 Oct 2022, via SSC), albeit mostly accepting the same syntax.
    Thanks,
    David.

    Comment


    • #3
      Dear David,

      Thank you for your answer. I added a datafile with some alternative data, but with the same variables.
      Is this sufficive?

      From Karin
      Attached Files

      Comment


      • #4
        Dear Karin,
        Thankyou for the dataset. Using this data, and modifying the code from your original message, here is the result of using the latest version of metan:

        Code:
        format %-1s Study Setting Country Population
        metan Ndel Npart, proportion transform(ftt) random denom(100) label(namevar=Study) labtitle(Study) by(Setting) nooverall nowt nosubgroup forestplot(lcols(Country Population) xlabel(0(2)10) range(-1 10) title("Forest plot point prevalence", box bexpand))
        The resulting plot is below. Could you describe what changes you would like to make?
        Thanks,
        David.


        Click image for larger version

Name:	karen_van_os.png
Views:	1
Size:	61.4 KB
ID:	1711502


        Comment


        • #5
          Dear David,

          Thank you for your time. This looks similar to what I created.

          What I would like to change is for a few boxes to look different. For example a white dot in the boxes in study B, D and C (or something else to visually distinguish them, preferably without using colour). So it is easy to see that they differ on a characteristic. Is this possible?

          With kind regards,
          Karin

          Comment


          • #6
            Here is an example. In this images I put the diamonds in by hand, but they aren't in the exact same place. Which makes it look somewhat messy.
            Attached Files

            Comment


            • #7
              Dear David (or other reader),

              Did you manage to have a second look at my question?
              Thank you for your time.


              With kind regards,
              Karin

              Comment


              • #8
                Dear Karin,
                Apologies, I have been away from the office.
                The solution is to use the plotid() option to flag the observations which you wish to differentiate; and then to use options plot#opts() to apply the chosen differentiation to the forest plot.

                For example:
                Code:
                . gen flag = inlist(Study, "B (2016)", "C (2013)", "D (1998)")
                . metan Ndel Npart, proportion transform(ftt) random denom(100) label(namevar=Study) labtitle(Study) by(Setting) nooverall nowt nosubgroup ///
                    forestplot(lcols(Country Population) xlabel(0(2)10) range(-1 10) title("Forest plot point prevalence", box bexpand) ///
                    point2opt(mcolor(white))) plotid(flag, list)
                The first line defines an indicator variable to differentiate studies B, C and D from the rest.
                We then run metan as before, but include plotid(flag) as an option to initiate the differentation. The ,list suboption just prints out a list of observations together with the value assigned to them by plotid(), and it is this value which you should use when applying forestplot visual options.
                Here, we use the option point2opts(mcolor(white)). This means, change the inner points to white, but only for those observations assigned a value of 2 in the list above. That is, studies B, C and D.

                Does that make sense? The resulting plot is below.
                Best wishes,
                David.


                Click image for larger version

Name:	karen_van_os(2).png
Views:	1
Size:	43.1 KB
ID:	1714027

                Comment

                Working...
                X