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: Overlay multple axes' labels?

From   Nick Winter <>
To   Stata List <>
Subject   st: Overlay multple axes' labels?
Date   Thu, 04 Mar 2010 15:05:00 -0500


I'm trying to make a single graph that combines three data series, which are themselves on three different scales. I can get everything I want, except for labeling the y-axes for plots 2 and 3.

The following demonstrates the problem: I want the volume labels (0 and 10,000) and the closing price change (-50, 0, and 50) to be on top of each other, rather than having the latter on a separate axis to the right of the former.

* begin example
sysuse sp500

gr twoway connected high date, yaxis(1) ///
    ysca(ra(500) axis(1)) ///
  || bar volume date, yaxis(2) ///
    ysca(alt ra(200000) axis(2)) ///
    ylab(0 10000, angle(horiz) grid labsize(small) axis(2)) ///
  || bar change date, yaxis(3) ///
    ysca(alt ra(-250 600) axis(3)) ///
    ylab(-50 0 50, angle(horiz) labsize(small) axis(3)) ///
* end example

Am I missing something obvious?

I messed with creating the three plots separately and using -graph combine- to put them together in a single column, but the different widths of the y labels across the plots means that the x-axes don't line up with each other, even with the -xcommon- option.

Something like:

* begin second example
gr twoway connected high date, xsca(off) ///
  graphregion(margin(b 0)) name(one, replace)

gr twoway bar volume date, ysca(alt) xsca(off) ///
  ylab(0 10000, angle(horiz) grid labsize(small)) ///
  graphregion(margin(t 0 b 0)) ///
  name(two, replace)

gr twoway bar change date, ysca(alt) ///
  ylab(-50 0 50, angle(horiz) labsize(small)) ///
  graphregion(margin(t 0)) ///
  name(three, replace)

gr combine one two three, col(1) xcommon
* end second example

Any thoughts?
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:

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