Announcement

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

  • marginsplot: x-axis gap between binary variable

    Hi,
    after a regression I use the command

    margins, at(group=(0 1))

    to plot a marginsplot. But the x-axis gap between 0 and 1 is so big, it takes to complete graph. How can I change (lower) this gap?

    Thanks
    -Nick

  • #2
    You can specify an xscale range in excess of your high end point (in your case >1). However, I struggle to see how useful this is...

    Code:
    *IN THIS CASE, THE GAP WILL BE HALF THE ORIGINAL GAP
    marginsplot, xscale(range(0 2) noextend)

    Comment


    • #3
      The gap is half but the graph is still that big. Any other possibility?

      Comment


      • #4
        You might find the undocumented margins option saving. See help undocumented and help margins_saving. This option will create a Stata dataset with the output from margins that you can then graph with any number of Stata commands.

        Comment


        • #5
          I think that you are confounding two issues here: 1) Adjusting the range of the x-axis so as to affect the width of the plot 2) Adjusting the dimensions of the graph as a whole. Your post #1 suggests the former but you appear to want the latter. Here are some ideas

          i) You can specify either -xsize()- or -ysize()- option to adjust dimensions.
          ii) To have equal height and width, specify -aspectratio(1)- in conjunction with (i)
          iii) If unable to get the desired dimensions, export graph in eps or picture form and adjust dimensions externally.

          Code:
          sysuse auto
          qui reg price mpg foreign
          qui margins, at(foreign=(0,1))
          marginsplot
          Click image for larger version

Name:	full.png
Views:	1
Size:	11.3 KB
ID:	1372366


          Reducing dimensions by changing -xsize()- and requiring that height=width by specifying -aspectratio(1)-

          Code:
          marginsplot, xsize(2) aspectratio(1)

          Click image for larger version

Name:	reduced.png
Views:	1
Size:	11.7 KB
ID:	1372367

          Comment


          • #6
            Alternatively, you can play with the x labels by adding buffers at either end.

            Code:
             marginsplot, xlab(-.25 " " 0 "Domestic" 1 "Foreign" 1.25 " ", notick)
            Click image for larger version

Name:	Graph.png
Views:	2
Size:	6.9 KB
ID:	1372380

            Comment


            • #7
              That worked perfect for me, thank you.

              Comment

              Working...
              X