Actual problem: I'm using the user-written combomarginsplot (SSC). When separating plots from two files using marginsplots's by() option, I cannot figure out how to customize certain text separately in each graph. Specifically, I want to place text over the second graph only, and the subtitle or label space is already spoken for. This is the code I used, which places the text over both graphs in the form of a note in file#opts positioned north:
Code:
combomarginsplot MERProsocial2009 MERProsocial2019, labels("2009" "2019") /// noci /// by(_filenumber) /// xsize(5.5) ysize(3) /// legend(order(1 "{bf:Suffering}" 2 "{bf:Struggling}" 3 "{bf:Thriving}") /// rows(1) title("SWB Outcome Categories" " ", size(*1.2)) region(fcolor(dimgray) /// lcolor(navy) lwidth(thick) margin(medium)) ) /// file2opts(note("(not a significant predictor in 2019)", span size(*1.1) position(n))) /// plot1opts(lpattern(solid) ms(O) color(purple) msize(medlarge) ) /// plot2opts(lpattern(solid) ms(D) color(blue) msize(medlarge) ) /// plot3opts(lpattern(solid) ms(T) color(green) msize(medlarge) ) /// yline(0, lwidth(medium) lcolor(gray) lpattern(dash)) /// ytitle("Pr(SWB Outcomes)", size(*1.2) ) /// xlabel(1.7(.5)6.7, labsize(small)) /// xtitle("Household Income", size(*1.2)) /// subtitle(, position(11) ring(0) margin(1 1 1 1) nobexpand size(*1.1) /// justification(center) color(black) bcolor(dimgray) /// lcolor(navy) lwidth(medthick)) /// byopts(title("Average Marginal Effects of {bf:Prosocial Behavior} on SWB Outcomes 2009 vs. 2019", /// color(black) size(*1.2) margin(medium)) /// subtitle(, margin(medsmall) size(*1)) /// legend(position(12)) /// iscale(*1.1) imargin(medium)) /// name(comboMERProsocial, replace)
I need that note text to be on top of the second graph but not the first graph. I believe I've got a comparable demo here of the sample problem.
Code:
*starting with example from combomarginsplot help file sysuse auto oprobit rep78 i.foreign mpg price weight margins foreign, at(mpg=(10(5)50)) expression(predict(outcome(1))+predict(outcome(2))) saving(file4, replace) margins foreign, at(mpg=(10(5)50)) expression(predict(outcome(4))+predict(outcome(5))) saving(file5, replace) *making g1 combomarginsplot file4 file5 , labels("Outcomes 1&2" "Outcomes 4&5") noci /// title("file#opts works as expected here") /// file1opts(pstyle(p1) color(purple) lpattern(solid) msize(huge)) /// file2opts(pstyle(p2) color(pink) lpattern(dash) msize(small)) /// legend(pos(0)) /// savefile(g1, replace) /// name(g1, replace) *making g2 combomarginsplot file4 file5 , labels("Outcomes 1&2" "Outcomes 4&5") noci /// by(_filenumber) /// byopts(legend(pos(0)) title("file#opts... does not work here, but why not?")) /// file1opts(pstyle(p1) color(purple) lpattern(solid) msize(huge)) /// file2opts(pstyle(p2) color(pink) lpattern(dash) msize(small) /// note("(wish this was atop one graph instead of both)", span position(n))) /// savefile(g2, replace) /// name(g2, replace) *combining graph combine g1 g2, xsize(6) ysize(3)
This could be because of how combomarginsplot works, by appending the saved margins file (so that I do not have two "files" for which I can declare options anymore?), but the help file says I can use file#opts, so I am guessing I'm not clear on how this works. I welcome anyone's advice. Thanks for your time.
This is what the demo code using the example dataset creates:
Array
0 Response to combomarginsplot and file#opts question about text over just one graph
Post a Comment