Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Moving legends in combined graphs


From   Nick Winter <[email protected]>
To   Stata List <[email protected]>
Subject   st: Moving legends in combined graphs
Date   Wed, 17 Mar 2010 14:51:29 -0400

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                  [email protected] 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index