Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Graph twoway: Multiple axis and order of plots


From   Peter Uhrmacher <peter.uhrmacher@gmx.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Graph twoway: Multiple axis and order of plots
Date   Thu, 06 Jul 2006 16:55:54 +0200

Dear Nick,

adding yaxis(1 2) was part of the solution, I only had yaxis(2) and axis(2) in my code. However, there is still a minor problem left:

If I add

gen mpg2=mpg/10

to your example

and then do this (i.e. just use the newly created mpg2 instead of mpg for the bars and divide the labels (i.e. the range) by 10 as well)

twoway bar mpg2 rep78, yaxis(1 2) yla(1.8(.2)2.8, axis(2)) || line mpg rep78, yla(20 30, axis(1))

STATA uses the same range of values for the left and right axis. Any ideas?

Thanks a lot!!
Peter


-------- Original Message --------
Subject: Re: st: RE: Graph twoway: Multiple axis and order of plots
Date: Thu, 06 Jul 2006 16:30:47 +0200
From: Peter Uhrmacher <peter.uhrmacher@gmx.net>
To: n.j.cox@durham.ac.uk
References: <031173627889364697C50B3B266CBB8AD5BF94@GEOGMAIL.geog.ad.dur.ac.uk>

Thx a lot, the yaxis(1 2) was the solution, I only had yaxis(2) and
axis(2)...!

Nick Cox wrote:
> There is no concrete code to comment on here. I did this:
> . sysuse auto, clear (1978 Automobile Data)
>
> . collapse mpg, by(rep78)
> . l
>
> +-----------------+
> | rep78 mpg |
> |-----------------|
> 1. | 1 21 |
> 2. | 2 19.125 |
> 3. | 3 19.4333 |
> 4. | 4 21.6667 |
> 5. | 5 27.3636 |
> |-----------------|
> 6. | . 21.4 |
> +-----------------+
>
> . twoway bar mpg rep78, yaxis(1 2) yla(18(2)28, axis(2)) || line mpg rep78, yla(20 30, axis(1))
>
> and the line plot is on top of the bar plot, and I have two separate axes. Does that help?
> Nick n.j.cox@durham.ac.uk
> Peter Uhrmacher
>
>> it seems that I am unable to solve a rather simple problem... but I hope you can. What I would like to have is a "graph twoway" with a line plot and a bar plot. the line plot is supposed to use yaxis1, the bar plot is supposed to use yaxis2. at the same time, the bar plot is supposed to appear in the background (so that the lines appear on top of it). however, whatever I try it seems that the plots that use yaxis2 are always put on top of the others that use yaxis1... (which in my case means that the line plot is hidden behind the bars). Is there a solution? I'm sure there is.
>
> *
> * 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/
>
>

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