Announcement

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

  • Overlay line segments on graph

    Click image for larger version

Name:	Fig1.png
Views:	2
Size:	175.0 KB
ID:	1521376
    I've generated the figure above and would like to make two line segments on the X-axis, one to the left of 0.0286 and the other to the right of 0.0314. Here's the code I have so far:

    Code:
       #delimit;
       twoway 
       function y=normalden(x,0.03,0.0007), range(0.0272 0.0328)              ///
                  graphregion(color(white)) clstyle(foreground) ||, 
       plotregion(style(none))
       legend(off)
       xtitle("Mean sulfur dioxide concentration (ppm)")
       xlabel(0.0286 0.0293 0.0300 0.0307 0.0314, format(%6.4f))
       ylabel(none)
       yscale(off);
       #delimit cr
    Is there a way to do this? Any help would be appreciated.
    Attached Files

  • #2
    Something like the following? (What you want to do is not entirely clear to me.) Note use of xline()

    Code:
    #delimit;
       twoway 
       function y=normalden(x,0.03,0.0007), range(0.0272 0.0328)              ///
                  graphregion(color(white)) clstyle(foreground) ||
        
        , xline(0.0285, lpatt(shortdash)) xline(0.0315, lpatt(shortdash))
       plotregion(style(none))
       legend(off)
       xtitle("Mean sulfur dioxide concentration (ppm)")
       xlabel(0.0286 0.0293 0.0300 0.0307 0.0314, format(%6.4f))
       ylabel(none)
       yscale(off);
       #delimit cr

    Comment


    • #3
      Dear Stephen:
      Thank you for your response. This figure is part of a hypothesis test and the horizontal axis represents all possible sample means, and the observed sample mean is 0.0314 ppm. I'd like to highlight the "extreme" values of sample means which for this two-tailed test lie to the right of 0.0314 ppm and to the left of 0.0286 ppm.

      The horizontal axis on this figure runs from 0.0272 to 0.0328. So I would like to darken/thicken/color the x-axis from from 0.0272 to 0.0286 and then again from 0.0314 to 0.0328. I hope that's a bit clearer.

      Thanks again!
      Last edited by Gautam Sethi; 22 Oct 2019, 06:03.

      Comment


      • #4
        I added the thick lines I want using a different program but I'd love to be able to do this in Stata.
        Click image for larger version

Name:	Fig3.png
Views:	1
Size:	175.5 KB
ID:	1521442

        Comment


        • #5
          Some technique:

          Code:
          #delimit;
             twoway
             function y=normalden(x,0.03,0.0007), range(0.0272 0.0328)              ///
                        graphregion(color(white)) clstyle(foreground) || ///
          (scatteri -25 0.0266  25 0.0286, connect(line) mcolor(none) lwidth(vvvthick) lcolor(red)) ///
          (scatteri -25 0.0314  -25 0.0334, connect(line) mcolor(none) lwidth(vvvthick) lcolor(red)),
             plotregion(style(none) )
             legend(off)
             xtitle("Mean sulfur dioxide concentration (ppm)")
             xlabel(0.0286 0.0293 0.0300 0.0307 0.0314, format(%6.4f))
             xscale(r(0.0286 0.0334) noextend)
             ylabel(none)
             yscale(off);
             #delimit cr
          See

          Code:
          help tw scatteri


          Click image for larger version

Name:	Graph.png
Views:	1
Size:	21.0 KB
ID:	1521522

          Comment


          • #6
            Originally posted by Andrew Musau View Post
            Some technique:

            Code:
            #delimit;
            twoway
            function y=normalden(x,0.03,0.0007), range(0.0272 0.0328) ///
            graphregion(color(white)) clstyle(foreground) || ///
            (scatteri -25 0.0266 25 0.0286, connect(line) mcolor(none) lwidth(vvvthick) lcolor(red)) ///
            (scatteri -25 0.0314 -25 0.0334, connect(line) mcolor(none) lwidth(vvvthick) lcolor(red)),
            plotregion(style(none) )
            legend(off)
            xtitle("Mean sulfur dioxide concentration (ppm)")
            xlabel(0.0286 0.0293 0.0300 0.0307 0.0314, format(%6.4f))
             xscale(r(0.0286 0.0334) noextend)
            ylabel(none)
            yscale(off);
            #delimit cr
            See

            Code:
            help tw scatteri


            [ATTACH=CONFIG]n1521522[/ATTACH]
            Dear Andrew:
            This is perfect! Thank you so very much!!!

            G.

            Comment


            • #7
              Sorry to bother folks again, but is there a nice and easy way to also place a couple of dots on the figure (as seen in this figure)?
              Click image for larger version

Name:	Graph1.png
Views:	1
Size:	48.1 KB
ID:	1521816

              Comment


              • #8
                In #5, I recommended that you have a look at

                Code:
                help tw scatteri
                Had you done that, you would have answered your question. Drop all the options in my code, just leaving you with

                Code:
                (scatteri -25 0.0266 25 0.0286)
                Of course, you have to adjust the coordinates accordingly.

                Comment


                • #9
                  Originally posted by Andrew Musau View Post
                  In #5, I recommended that you have a look at

                  Code:
                  help tw scatteri
                  Had you done that, you would have answered your question. Drop all the options in my code, just leaving you with

                  Code:
                  (scatteri -25 0.0266 25 0.0286)
                  Of course, you have to adjust the coordinates accordingly.
                  Thank you!

                  Comment

                  Working...
                  X