[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: RE: labels on bar graphs

From   "Michael Blasnik" <>
Subject   Re: st: RE: RE: labels on bar graphs
Date   Tue, 1 Jul 2008 11:03:39 -0400

I have written a brief ado to address this problem with graphs.  It
isn't fully automated in terms of selecting the specific numbers, but
a wrapper to select "nice" numbers for the labeled ticks could be
used.  It's short enough that I can just list it:

program define labpct
version 9.2
args start step end decimals loc
forvalues i=`start'(`step')`end' {
	local pct: di %5.`decimals'f `i'*100
	local pct = trim("`pct'")
	local pctlist `"`pctlist' `i' "`pct'%" "'
c_local `loc' `"`pctlist'"'

The typical syntax is something like

labpct 0 .02 .1 0 ylab

The arguments are starting value, step value, max value, number of
digits after decimal in the percentage, and name of local macro to
contain the result.  This command would result in a local macro called
ylab that looks like this:

di `"`ylab'"'
 0 "0%"  .02 "2%"  .04 "4%"  .06 "6%"  .08 "8%"  .1 "10%"

A subsequent graph command could then be :

graph ...., ylab(`ylab')

Michael Blasnik

On Tue, Jul 1, 2008 at 10:24 AM, Richard Goldstein
<> wrote:
> I agree that Nick's suggestion would solve my, and other people's, problem
> completely
> I also did not understand Frank's comment
> Rich
*   For searches and help try:

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