Statalist


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

st: Common legend with -graph combine-


From   Morten Vejs Willert <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: Common legend with -graph combine-
Date   Wed, 11 Feb 2009 13:21:49 +0100

I have a question regarding the -graph combine- command: Has anyone figured out how to get a common legend on a combined graph, that will identify the groups represented in the individual graphs. I want combine 6 graphs (showing 6 different measures over time on the same two groups) and would like 1 (and not 6) legends to appear on the final combined graph.

I have tried suppressing the legend on five of the graphs and then leaving it on one graph. Unfortunately this has the downside, that the graph area on the graph with the legend becomes half the size of the graph areas of the other graphs.

Ideas for a solution to this will be greatly appreciated.

I have tried constructing an example from one of the supplied Stata dataset:


***********************************************************************

sysuse cancer.dta, clear

* making scatterplot A
twoway  (scatter age studytime if drug==1     ///
  , msymbol(O) lpattern(-) lcol(black) mcol(black)) ///
  (scatter age studytime if drug==2     ///
  , msymbol(O) lpattern(solid) lcol(blue) mcol(blue)) ///
  , title("Scatterplot A")       ///
  legend(order(1 "Drug 1"  2 "Drug 2"))    ///
  name(ScatA, replace)

* making scatterplot B
twoway  (scatter age studytime if drug==2     ///
  , msymbol(O) lpattern(-) lcol(blue) mcol(blue))  ///
  (scatter age studytime if drug==3     ///
  , msymbol(O) lpattern(solid) lcol(red) mcol(red)) ///
  , title("Scatterplot B")       ///
  legend(order(1 "Drug 2"  2 "Drug 3"))    ///
  name(ScatB, replace)


* combining scatterplots A and B
graph combine ScatA ScatB


***********************************************************************


Best regards

Morten Vejs Willert

*
*   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