Statalist


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

Re: st: legend in the hole for combined graph


From   Gary Longton <[email protected]>
To   [email protected]
Subject   Re: st: legend in the hole for combined graph
Date   Tue, 31 Mar 2009 11:43:47 -0700

<>

Uli provided a creative solution which generated a separate graphic legend from scratch for the 4th panel of a combined graph. There is another solution using Vince Wiggins' -grc1leg- that may be a little less complicated.

a) use the ring() and position() options of -grc1leg- to place the legend in the empty 4th quadrant, i.e. ring(0) position(5)

b) pad the original legend with enough outer margin to center the legend in the 4th quadrant, using the legend(bmargin()) option.

c) note that -grc1leg- uses the legend from the first graph unless otherwise specified with the legendfrom() option.

d) I recommend using -graph display- with xsize() and ysize() options immediately after using -grc1leg- for control of the aspect ratio, as the xsize() and ysize() region_options are not recognized by -grc1leg-, and the aspect ratio of the combined graph will affect the centering of the legend with the legend bmargin() values in addition to the effect on many other things about the combined graph appearance.

an example:
**********
 .webuse auto, clear
 .scatter price weight, yaxis(1) || scatter mpg weight, yaxis(2) ///
    legend(cols(1) bmargin(b=22 r=20)) name(g1, replace)
 .scatter price displacement, yaxis(1) ///
    || scatter mpg displacement, yaxis(2) name(g2, replace)
 .scatter price length, yaxis(1) ///
    || scatter mpg length, yaxis(2) name(g3, replace)

 .grc1leg g1 g2 g3, name(g4, replace) position(5) ring(0)
 .graph display g4, xsize(9) ysize(6.5)
**********

- Gary


Lloyd Dumont wrote:

Hello.  Is there an easy way to combine graphs using either graph combine or grc1leg, but putting the resulting legend in the hole?  For example, imagine a 4-panel graph with graphs in 3 of the 4 panels, and then a legend in the 4th panel?

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index