Graphics Reference
In-Depth Information
-variable is a date
variable, namely,
twoway tsline
and
twoway tsrline
.The
tsline
command is similar
to the
line
command, and the
tsrline
is similar to the
rline
command, but both of these
ts
commands offer extra features, making it easier to reference the
Stata has additional commands for creating line plots where the
x
-variable in terms of
dates. Note that these commands are not currently documented in [
G
]
graph
but are doc-
umented via
help tsline
. We will use the
sp2001ts
data file, which has the prices for
the S&P 500 index for 2001 with the trading date stored as a date variable named
date
.
Before saving the file
sp2001ts
,the
tsset date, daily
command was used to tell Stata
that the variable
date
represents the time variable and that it represents daily data.
x
twoway
tsline
close
The
tsline
(time-series line) graph
shows the closing price on the
y
-axis
and the date on the
x
-axis. Note that
x
we did not specify the
-variable in the
graph command. Stata knew the
variable representing time because we
previously issued the
tsset date,
daily
command before saving the
sp2001ts
file. Note that if you save the
data file, Stata remembers the time
variable, and you do not need to set it
again.
Uses sp2001ts.dta & scheme vg s1c
1Jan01
1Apr01
1Jul01
1Oct01
1Jan02
Date
twoway
tsrline
low high
We can also use the
tsrline
(time-series range) graph to show the
low price and high price for each day.
Uses sp2001ts.dta & scheme vg s1c
1Jan01
1Apr01
1Jul01
1Oct01
1Jan02
Date
The electronic form of this topic is solely for direct use at UCLA and only by faculty, students, and staff of UCLA.