Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Fiedler, James (JSC-SK)[USRA]" <james.fiedler-1@nasa.gov> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | st: RE: Moving legends in combined graphs |
Date | Wed, 17 Mar 2010 14:14:55 -0500 |
Is this the kind of thing you want? The following should put the legend in the 2,1 and 1,3 positions (the second-to-last command shuts off the plot region of graph b). gr two scatter mpg mpg price, name(a, replace) legend(off) gr two scatter mpg mpg price, name(b, replace) yscale(off) xscale(off) leg(, ring(0) pos(0)) gr_edit .plotregion1.draw_view.setstyle, style(no) graph combine a b a a a b, rows(2) James ________________________________________ From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Winter [nwinter@virginia.edu] Sent: Wednesday, March 17, 2010 1:51 PM To: Stata List Subject: st: Moving legends in combined graphs Hi, I'm trying to automate a modification to -grc1leg-, to move the single legend into a "hole" in the combined plot. There are two ways I can get what I want: sysuse auto, clear gr two scatter mpg mpg price, name(a, replace) legend(col(1)) * Way One grc1leg a a a , ring(0) pos(4) name(drag) gr_edit .legend.DragBy 21 -15 * Way Two grc1leg a a a , ring(0) pos(4) name(setmargin) gr_edit .legend.style.editstyle boxmargin(0 15 20 0) editcopy So my question is whether anyone can give me advice on automating figuring out the amount to drag (method 1) or the size of margins needed (method 2) to put the legend in the middle of an arbitrarily specified hole in the grid of plots? Ideally I'd like to be able to do something like: grc1leg a a a a a, hole(5) putlegend(5) Which I can achieve by trial and error with grc1leg a a a a a, hole(5) ring(0) gr_edit .legend.DragBy 21 0 which moves the legend to the middle of the hole created by the hole() option. But to do that I need to figure out the size of the legend, and the size of the hole, I'd guess. Thanks for any thoughts. Nick Winter -- -------------------------------------------------------------- Nicholas Winter 434.924.6994 t Assistant Professor 434.924.3359 f Department of Politics nwinter@virginia.edu e University of Virginia faculty.virginia.edu/nwinter w S385 Gibson Hall, South Lawn Map: http://tinyurl.com/uvaSLmap * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/