Announcement

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

  • Setting same dimension when combining graphs

    Dear all,

    I am trying to combine two graphs from marginsplot but the first consistently has a different dimension (although I set its y-axis range equal to that of the second graph. Any idea on how to fix this?
    Here is the code I used and thank you in advance:

    Code:
    mean countabdisplayed if ab_mobile!="yes", over(co2ab_levels moral)
    marginsplot, name(ab_moral_CO2ab, replace) leg(off) ylabel(350(50)600 ,angle(0)) ///
    xlabel(0 `" "Low CO2" "abatement" "' 1 `" "High CO2      " "abatement       " "', labsize(small)) ytitle("Number of A-B pair presses") 
    
    
     mean countabdisplayed if ab_mobile!="yes", over(mon_inclevels moral) 
    marginsplot, name(ab_moral_moninc, replace) legend( cols(1) )ylabel(,angle(0)) ///
    xlabel(0 `" "No mon." "incentive" "' 1 `" "Low mon." "incentive" "' 2 `" "Medium mon." "incentive" "' 3 `" "High mon." "incentive" "', labsize(small) angle(30)) ytitle("")
    
    grc1leg ab_moral_CO2ab ab_moral_moninc,  position(6) legendfrom(ab_moral_moninc) ring(3)
    Click image for larger version

Name:	Figure 2 SHEDS.png
Views:	1
Size:	85.9 KB
ID:	1657886

  • #2
    I think the misaligned vertical axes are caused by Stata's insistence on extending the y-axis to include the most extreme values of the confidence intervals. If I am correct, you can get the y-axes to align with one another by forcing both graphs to have a wider y-axis range. Try using the option
    Code:
    ylabel(300(50)650, angle(0))
    on BOTH -marginsplot- graphs before you combine them. Also to give you more control over the combined graph, I suggest using my command -grc1leg2- instead of -grc1leg-.

    Comment


    • #3
      Thanks for the answer and for making me know about -grc1leg2-. With some adjustment, I have been able to solve the problem. Here is the code and the graph I got:

      Code:
      mean countabdisplayed if ab_mobile!="yes", over(co2ab_levels moral)
      marginsplot, name(ab_moral_CO2ab, replace) leg(off) ylabel(200(50)700 ,angle(0)) /// 
      xlabel(0 `" "       Low CO2" "       abatement" "' 1 `" "High CO2      " "abatement       " "', labsize(small) angle(0)) ///
      ytitle("Number of A-B pair presses") title("")  yline(310.5, lcolor(dkgreen)) yline(595.3, lcolor(dkgreen)) xtitle(, height(7))
      
      
       mean countabdisplayed if ab_mobile!="yes", over(mon_inclevels moral) 
      marginsplot, name(ab_moral_moninc, replace)  ylabel(200(50)700 ,angle(0)) /// 
      xlabel(0 `" "No mon." "incentive" "' 1 `" "Low mon." "incentive" "' 2 `" "Medium mon." "incentive" "' 3 `" "High mon." "incentive" "', labsize(small) angle(0)) /// 
      legend(size(*0.8)) ytitle("") title("") xtitle(, height(7))
      
      grc1leg2 ab_moral_CO2ab ab_moral_moninc,  position(6) legendfrom(ab_moral_moninc) ///
      ring(3) title("Estimated means of AB pairs with 95% CIs", size(medium)) ycommon
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	86.9 KB
ID:	1659001

      Comment

      Working...
      X