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

Re: st: how to make the X axis increment by a certain value

From   Roger Newson <>
Subject   Re: st: how to make the X axis increment by a certain value
Date   Wed, 23 Nov 2005 16:45:19 +0000

At 16:04 23/11/2005, HW wrote:
Hi all,

I know in Stata allows us to set the axis like xlabel(1(1)10), but if
I am running a loop and the min and max of X axis vary from graph to
graph, can I tell Stata to label X axis at every 1 value of X (or
every 2) without specifying the min. and max. of X? I am sure there is
a way to do it in Stata.
You might like to use the -regaxis- package, which you can download from SSC within Stata using the -ssc- command. If you do this, and type

regaxis x, cycle(2) ltick(xlabs)
twoway scatter y x, xlabel(`xlabs')

then -regaxis- will store in the macro xlabs a sequence of x-axis labels, spanning the range of x and separated by a cycle length of 2, and -twoway scatter- will use `xlabs' as the X-axis labels.

The -regaxis- package is a general solution to creating regular axis label sequences and ranges, which can either be linear (using the -regaxis- program) or logarithmic (using the -logaxis- program). You can find more about it by typing

findit regaxis

and reading the on-line help.

I hope this helps.


Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
Division of Asthma, Allergy and Lung Biology
King's College London

5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
or 020 7848 6605 International +44 20 7848 6605

Opinions expressed are those of the author, not the institution.

* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index