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

Re: st: Axis label annoyance


From   [email protected]
To   [email protected]
Subject   Re: st: Axis label annoyance
Date   Tue, 02 Aug 2005 15:45:33 -0500

One way would be to use the -tlabel- option, something like:

sysuse sp500, clear
tsset date, daily
twoway tsline high low , tlabel(31jan2001 31dec2001, format(%dmd) alt) 
xtitle("")

If you have a lot of dates to enter, the following code picks up the 
last day of the month:


sysuse sp500, clear
tsset date, daily

gen year = year(date)
levelsof year, local(years)

local day31  "Jan", "Mar", "May", "Jul", "Aug", "Oct", "Dec"
local day30  "Apr", "Jun", "Sep", "Nov"

local month = c(Mons)
foreach k of local years {
foreach l of local month {
	if inlist("`l'", "`day31'") == 1 {
	local months "`months'31`l'`k' "
	}
	
	if inlist("`l'", "`day30'") == 1 {
	local months "`months'30`l'`k' "
	}

	if mod(`k', 4)==0 & "`l'" == "Feb"  {
		local months "`months'29`l'`k' "
	}
	if mod(`k', 4)==1 & "`l'" == "Feb" {
		local months "`months'28`l'`k' "
	}
}
}

twoway tsline high low , tlabel("`months'", format(%dmd) alt) xtitle
("")


Scott


----- Original Message -----
From: "Eric G. Wruck" <[email protected]>
Date: Tuesday, August 2, 2005 9:21 am
Subject: st: Axis label annoyance

> Hi there:
> 
> I'm working on some overlaid graphs where the x-axis is the date. 
> The date within the Stata file is always the last day of the 
> month. 
> However, when I go to create my twoway graph, Stata labels the 
> axes 
> with dates that are the first day of the month (e.g., 01 Oct 00) --
> 
> dates that are not actually found on any record within the file.  
> Why 
> does Stata do this?  I will try re-formatting the dates but it 
> doesn't seem to me that I should have to do this.  Any thoughts?
> 
> Thanks,
> 
> Eric
> 
> -- 
> 
> ===================================================
> 
>        Eric G. Wruck
>        Econalytics
>        2535 Sherwood Road
>        Columbus, OH  43209
> 
>        ph:      614.231.5034
>        cell:    614.330.8846
>        eFax:    614.573.6639
>        eMail:   [email protected]
>        website: http://www.econalytics.com
> 
> ====================================================
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index