Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: Moving legends in combined graphs

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


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 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         e
University of Virginia w
S385 Gibson Hall, South Lawn  Map:
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index