Statalist The Stata Listserver


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

st: RE: nonlinear relationships between multiple axis


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: nonlinear relationships between multiple axis
Date   Mon, 18 Jun 2007 17:00:05 +0200

--- Steinar Fossedal wrote:
> I have three variables where variable A can be derived from each of the
> two others (B & C). I now want to create a line-graph with the value of
> variable A on the y-axis and the corresponding values of B and C on
> xaxis 1 and 2 respectively.
> 
> In case this was as hard to understand as it was to explain, I'll
> elaborate with an example:
> 
> clear
> set obs 100
> gen B = _n
> gen C = B^.5
> gen A = B
> line A B
>
> I want to include a second x-axis which shows the corresponding values
> of C.

*--------- begin example ----------
clear
set obs 100
gen B = _n
gen C = B^.5
gen A = B

forvalues i = 0(20)100 {
	local c = round(`i'^.5, .1)
	local c = substr("`c'",1,3)
	local x `"`x' `i' "`c'" "'
}
twoway line A B || /*
    */ scatter A B, /* 
    */ msymbol(i) xaxis(2) /*
    */ legend(off) /*
    */ xlab(`x', axis(2) format(%9.1f)) /*
    */ xtitle("C", axis(2))
*------------ end example ------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------



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