Announcement

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

  • Graphic layers /twoway): points and lines

    Hello,

    I want to make a graph that puts lines ("ylines", "xlines") in front of the points produced by "scatter". However, the advice to put the front layer at the end of the syntax does not work. I might put it everywhere, the lines are always hidden by the points.

    Maybe just a small but one needs to knwo :-)

    Thanks a lot in advance,
    Michael



    #delimit;
    graph twoway scatter y x in 1 , msymbol(n) color(white)

    || scatter y x if ev0==1 , color(sand) msymbol(p)

    || scatter y x if evd==1 , color(sandb) msymbol(p)
    lalign(inside)




    xtitle("prior mean")
    ytitle("prior SD")
    title("Region of Evidence")

    scheme(s1color)
    legend(off)

    || scatter y x if confl==1 , color(gs12) msymbol(p) ,
    ylab(0(`sdstep')`sdmax')
    yline(0(`sdstep')`sdmax' , lcolor(gs10) )

    xlab(`lower'(`estep')`upper')
    xline(`lower'(`estep')`upper' , lcolor(gs10) )

    text( `sd0' `e0' "* (prior)" , place(e))
    text( `sd1' `e1' "* obs" , place(e))
    text( `sdp' `ep' "* (posterior)" , place(e))
    text( `lab1' `upper' "Effect > 0" , place(w) bcolor(sand) color(black) lcolor(black) size(large) box )
    text( `lab2' `upper' "Effect > `delta'" , place(w) bcolor(sandb) color(black) lcolor(black) size(large) box)
    text( `yconfl' `lower' "prior-data conflict" , place(e) size(small))
    text( `yconfl' `upper' "prior-data conflict" , place(w) size(small))
    `di_e0' `di_ep'
    `di_sd0' `di_sdd'



    ;

  • #2
    Added lines are always regarded as backdrop relative to other graphic elements, at least in the same command. To make them prominent, you could increase their width. An alternative is to set up your own lines with something like

    Code:
    . webuse grunfeld, clear
    
    . line invest year if company == 1 , xli(1939 1945)
    
    . su invest if company == 1
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
          invest |         20      608.02    309.5746      257.7     1486.7
    
    . line invest year if company == 1 , xli(1939 1945) || scatteri 0 1939 1500 1939, recast(line) || scatteri 0 1945 1500 1945, recast(line)

    Comment


    • #3
      Thank you, Nick. Actually, I would need a whole grid (produced by "xline" and "yline") as well 1-2 extra lines in the foreground. But maybe I have to leave my ado as it is.
      Click image for larger version

Name:	Graph11.png
Views:	1
Size:	31.0 KB
ID:	1586746

      Comment


      • #4
        You can write code to write code. For example, for a grid at x = -2(1)2 extending from y = 0 to y = 2 you could go

        Code:
        local xcall 
        
        forval x = -2/2 { 
              local xcall `xcall' || scatteri  0 `x' 2 `x'  
        }
        and then refer to `xcall' within your main command.

        Comment


        • #5
          Thank you.

          Comment

          Working...
          X