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: RE: Moving legends in combined graphs

From   "Martin Weiss" <>
To   <>
Subject   st: RE: Moving legends in combined graphs
Date   Wed, 17 Mar 2010 20:46:10 +0100


How do these graphs come into being? In your example, you reuse the "a"
graph three times, but in reality I bet you have different ones. Note that
with the -by- option, you do get a nice placement for the -legend-:

sysuse auto, clear
tw (scatter mpg price), by(, legend(on position(0) at(6))) by(rep78)


-----Original Message-----
[] On Behalf Of Nick Winter
Sent: Mittwoch, 17. März 2010 19:51
To: Stata List
Subject: st: Moving legends in combined graphs


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:

*   For searches and help try:

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