Announcement

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

  • How to move estimates to center of the graph?

    Hi all,

    I am trying to plot estimates and their associated 95% CI into one graph. Actually, I successfully made a graph, but the distance of estimates between country A and B is huge. So, I want to narrow down that distance by moving the estimates of the two countries to the graph center, any advice is highly appreciated. Thank you.
    Data
    Code:
    clear
    input float(id country beta ub lb)
     1 0  -.085 -.068 -.101
    11 1 -.115  -.089 -.141
    end
    label values country country
    label def country 0 "A", modify
    label def country 1 "B", modify
    Code
    Code:
    twoway    (scatter beta country, msymbol(s))                    ///
            (rspike ub lb country), xla(0/1, valuelabel noticks)  ///
            legend(label(1 "Estimates") label(2 "95% CI"))
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	157.2 KB
ID:	1643515

    Last edited by Matthew Williams; 04 Jan 2022, 04:01.

  • #2
    Just extend the x scale range. At the moment you have the values 0 and 1.

    Code:
    xsc(r(-2 4))

    Comment


    • #3
      xscale,
      Code:
      twoway  scatter beta country, msymbol(s) || ///
              (rspike ub lb country), xla(0/1, valuelabel noticks)  ///
              legend(label(1 "Estimates") label(2 "95% CI")) ///
              xscale(r(-3 4))
      xscale and xsize,
      Code:
      twoway  scatter beta country, msymbol(s) || ///
              (rspike ub lb country), xla(0/1, valuelabel noticks)  ///
              legend(label(1 "Estimates") label(2 "95% CI")) ///
              xscale(r(-3 4)) xsize(4)

      Comment


      • #4
        Thank you, Andrew and Øyvind

        Thank you so much for your quick help. It works perfectly. I have an additional question regarding your code, that how do you know that xscale should range from -2 to 4 (or -3 to 4) in my case?
        Last edited by Matthew Williams; 04 Jan 2022, 04:06.

        Comment


        • #5
          I should have perhaps specified -2 3 range as 0 1 is exactly in the middle of this.

          -2 -1 0 1 2 3

          It's mental mathematics, but not completely symmetrical in this case!

          Comment

          Working...
          X