Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# RE: st: Combining seperate graphs into one

 From Nick Cox <[email protected]> To "'[email protected]'" <[email protected]> Subject RE: st: Combining seperate graphs into one Date Thu, 7 Jun 2012 15:54:43 +0100

```If the -area- graph covers the -line- chart, why not draw it first?

twoway area var2 date, yaxis(1) || line var1 date, yaxis(2)

I don't know if either helps with your data, but

1. If differences tend to be small but interesting, it can help to calculate and plot the difference directly, as well as or instead of the raw variables.

2. Consider an offset, as in

SJ-7-1  gr0026  . . . .  Stata tip 42: The overlay problem: Offset for clarity
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . J. Cui
Q1/07   SJ 7(1):141--142                                 (no commands)
tip for graphing several quantities on a continuous axis

Nick
[email protected]

tashi lama

I have tried this option before and did it again after this post. With this command, having two xaxis complicates the graph than simplifies it. What this command does is place one axis at the bottom(which is convention) and other on the top of the graph(which makes no sense). I was actually trying to run two diff time series graphs with same date variable. Sth like this

date          var1   var2

01jan2010      2      1
02jan2010      4      9

twoway line var1 date, yaxis(1) || area var2 date, yaxis(2)

This is fine because it creates a single chart with two yaxis on opposite sides. but one common xaxis. The problem is since I am drawing a twoway area for var2, it covers the line chart of var1. That is why I wanted to have two xaxis one top of other to avoid overwritten graphs. One way was to check with xaxis(#) which you suggested, but weirdly it does the same exact thing except puts xaxis(2) on top of the chart which doesn't help at all.

I could have used graph combine to create chart with diff y and x axis but I was tryin to

1. avoid extra steps for saving graphs to combine
2. picture them as a single chart than two charts(diff y and xaxis)

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