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

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

st: RE: Adding Shaded Areas to Time Series Graph

From   Nick Cox <>
To   "''" <>
Subject   st: RE: Adding Shaded Areas to Time Series Graph
Date   Thu, 9 Feb 2012 18:12:18 +0000

I don't have access to 10.1 on this machine, which is not a Macintosh. I am using Stata 12.1. 

We don't have your data and it is difficult to guess at an analogue without knowing anything about them. 


1. The syntax -twoway function ..., range(varname1 varname2)- is not explicitly supported although it is indulged. There are two explicit syntaxes, -range(# #)- and -range(varname)-. I don't know how you expect -twoway function- to behave with this syntax. With a simple experiment 

set obs 100
gen x1 = _n
gen x2 = x1 + 50
twoway function 42, range(x1 x2)
twoway function 42, range(x1 x2) recast(area

I find that the range of -x2- is used and that -recast(area)- works as expected. 

2. In another experiment linked experiment this worked without problems:

gen t = ym(2000,12) + _n
tsset t, monthly
tsline x2 t, tlabel(2000m1(12)2010m1, format(%tm!2!0YY))

Here the explicitly specified limits for the labels are beyond the data limits. 


I've been trying to get the following code to work using the latest version of Stata 10 on Mac OS X. I have the following problems:

First, each area plot is displayed only as a line at the end of the specified range rather than the area itself.

Second, the tlabel option on the last line works fine, but what I really want for the t-axis option is tlabel(2000m1(12)2008m1, format(%tm!2!0YY) labsize(small)). Unfortunately, Stata says that 2000m1 is an invalid name and I don't understand why.

set scheme lean1
tsset service_date_month, monthly
twoway function y=0.3, range(epiccare_start epiccare_end) recast(area) color(gs12) 	|| 	///
function y=0.3, range(reg_bill_start reg_bill_end) recast(area) color(gs12) 			|| 	///
tsline GIM_99201 if tin(2002m5, 2007m8), 										///
title("CPT Code 99201 Trend" "May 2002 - August 2007" 							///
"General Internal Medicine", size(medium)) 										///
subtitle("") 																///
ytitle("Proportion") 															///
xtitle("Year") 																///
ylabel(0(0.1)0.3, labsize(small)) 												///
legend(off) 																///
lpattern(solid) 																///
tlabel(, format(%tm!2!0YY) labsize(small))

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index