Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: graph hbar and (xy)common


From   [email protected] (Vince Wiggins, StataCorp)
To   [email protected]
Subject   Re: st: graph hbar and (xy)common
Date   Wed, 10 Dec 2003 09:56:42 -0600

Ulrich Kohler <[email protected]> asks about using -graph combine- to stack
to separately drawn graphs, but he wants the plot regions of the graphs to
align,

> I have two graphs, produced with -graph hbar- and want to combine
> them underneath each other in one single graph. The first graph
> plots 28 country-means of a measurment, the second graph plots means
> of the same measurment for 4 groups of countries (i.e. European
> Union etc.)
>
> What I want to have is something like the following (Please use
> fixed-font):
>
>                  +-----------------------------------+
>          Romania |###################                | 
>          Bulgaria|##########                         |
>               :  |########                           |
>               :  |#######                            |
>               :  |####                               |
>   United Kingdom |##                                 |
>                  +-----------------------------------+
>                  +-----------------------------------+
>               EU |##                                 | 
>               :  |###############                    | 
>               CC |#######                            |
>                  +-----------------------------------+
>
> However, since the labels of the second graph are much shorter than
> those of the first, I end up with a picture like this:
>
>                  +-----------------------------------+
>          Romania |###################                | 
>          Bulgaria|##########                         |
>               :  |########                           |
>               :  |#######                            |
>               :  |####                               |
>   United Kingdom |##                                 |
>                  +-----------------------------------+
>            +-----------------------------------------+
>         EU |##                                       | 
>         :  |###############                          | 
>         CC |#######                                  |
>            +-----------------------------------------+
>
> [...]

For better or worse, -graph combine- does not really "understand" the pieces
of the graph it is combining (other than ability to ask them to tweak their
scales).  It is stacking the whole graphs, not the plotregions, titles, axes,
and other pieces separately.

Uli could try Nick Cox's <[email protected]> suggestion to use another
-over()- category rather than two graphs, or a variation on that idea using
-by()- to get two graphs.  Neither of these options will give him a horizontal
bar graph over a dot plot as he originally asked.

Uli can get what he wants, but it will likely requiring some iterating to get
the plotregions aligned.  When drawing his second graph, the one with the
shorter labels, Uli can add the suboption -axis(outergap(#)))- to his -over()-
option.  This will add spacing outside the category axis labels for this
graph.  The spacing is a percentage of graph width, so Uli may want to start
with something like outergap(20), but he will have to tweak this number and
recombine until his graphs align.


 
-- Vince
   [email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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