[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Combined Horizontal Box Blots do not line up
Ulrich Kohler <email@example.com> asks why the option -xcommon- is not doing
what he expects,
> I try to combine horizontal box blots underneath each other by using
> the -xcommon- option, but they do not line up.
> Here is an example for what I try to do:
> . sysuse auto, clear
> . graph box turn, over(rep78) name(g1, replace) horizontal
> . graph box turn, over(foreign) name(g2, replace) horizontal
> . graph combine g1 g2, xcommon cols(1)
> . graph combine g1 g2, ycommon cols(1)
> which doesn't work [...]
I ran Uli's example see that both graphs are already on a common X scale --
they both run from 30 to 50 with 5 ticks on the axis. -xcommon- would make
these axes common for Uli, if they were indeed different in the original
I think what Uli is asking is why aren't the plot regions forced to be the
same length in the combined graphs. (They are not in the original graphs
because the labels on the y-axis are of vastly different lengths.) That would
be a laudable goal, but it is not what -xcommon- means and not what
-graph combine- does.
-graph combine- combines whole graphs. It can squish the overall dimensions
of the graphs so that they take up the entire size of the combined graph's
dimensions, but it cannot reach into the two graphs and rip out pieces to
create a Franken-graph (with apologies to Mary Shelley).
It is not elegant, but Uli can get the plotregions to align by seeing to it
that the original graphs have the same length plotregion. Adding a left
margin to the first graph, using something like -graphregion(margin(l=15))-
will do the trick. Uli will have to fidget with the size of the margin.
Uli goes on to suggest,
> I can imagine a solution with reshaping the data and applying the
> -by()- option instead of the -graph combine- solution, but do you
> know an easier one?
And, that will work too.
* For searches and help try: