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, statalist.org is already up and running.


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

Re: st: Imposing a line graph into a bar graph


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Imposing a line graph into a bar graph
Date   Tue, 12 Apr 2011 19:35:48 +0100

Your strategy won't work.

-graph bar- and -twoway- are not compatible. You need to switch to
-twoway- to get this.

Here is a silly example, but some possibly useful technique.

webuse grunfeld, clear
keep if company == 1
keep if year < 1945
graph bar (asis) invest mvalue kstock , over(year)
gen year2 = year + 0.3
gen year3 = year - 0.3
twoway bar invest year3, barw(0.3) || bar mvalue year, barw(0.3) ||
bar kstock year2 , barw(0.3)
gen average = (invest + mvalue + kstock) / 3
twoway bar invest year3, barw(0.3) || bar mvalue year, barw(0.3) ||
bar kstock year2 , barw(0.3) || line average year

On offsets, see

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

which is accessible to all at the SJ website. (42: what a good number;
I should have taken that one myself.)

On Tue, Apr 12, 2011 at 7:21 PM, Syed Basher <syed.basher@yahoo.com> wrote:

> I am using Stata 11.2. I have generated a bar graph  using the following
> command:
> graph bar us uk jap, over(year)
>
> I have a  forth variable, which is the average of (us uk jap). I want to impose
> the  fourth variable (say x1) on the bar graph as a line graph. I have tried
> inserting the command for a line graph [twoway (line x1 year)] into the  above
> command, which didn't work. Your help/hint is much appreciated.

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index