Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Adding lines to graphs


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Adding lines to graphs
Date   Fri, 11 Nov 2005 10:50:43 -0000

Alternatively, it is not necessary to change the dataset size. 

Given y and x, you create two new variables: 

gen y1 = 0 in 1
replace y1 = y[1] in 2
gen x1 = 0 in 1
replace x1 = x[1] in 2 

line y1 x1 || line y x 

Admittedly, you still have to mess around 
with legends, line styles etc. So either
you alter your data a little, as above or
below, or you use -scatteri- as earlier
suggested. 

Nick 
[email protected] 

Ulrich Kohler
 
> [email protected] wrote:
> > I have a series of interconnected monotonically declining 
> plots that I am
> > presenting as a single connected line graph, i.e., a graph 
> that starts
> > relatively high on the y axis, declines, jumbs vertically 
> to a second high
> > point, declines again,etc (substantively describes a 
> relationship between
> > varying values of a hazard ratio and age). I can't figure 
> out how to add a
> > line going from the 0 point on the x axis to the initial 
> value of the
> > graph. I would be most appreciative of any suggestions. Thanks
> 
> I think you need to generate an observation with x=0. 
> Assuming that the y-value for x=0 should be y=0:
> 
> . set obs `=_N+1'
> . replace x = 0 in `=_N'
> . replace y = 0 in `=_N'
> . connected y x, sort
> 
> Or, if your dataset contains only x and y:
> 
> . input
> .  0 0
> .  end
> . connected y x, sort

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