Date: Thu, 9 Dec 1999 16:49:05 +0100 Frank Poppe "SAS(r) Discussion" Frank Poppe UUNET-NL (http://www.nl.uu.net) Re: y axis spacing for graphs - solved

Hello Peter,

I missed your original question, but saw your own answer. Here is some code that starts with a MIN and a MAX value, and from that computes a reasonable INCrement, new MIN and MAX that are whole multiples of INC and the NUMber of steps to go from the (new) MIN to MAX.

The code is based on an algorithm in the PLOTIT macro developed by Warren F Kuhfeld from SI, and I have been told that it is the same algorithm used in the SAS/Graph procedures.

range = max - min ; inc = 10 ** ceil(log10(range) - 1.0); if range / inc >= 7.5 then inc = inc * 2; if range / inc <= 2.5 then inc = inc / 2; if range / inc <= 2.5 then inc = inc / 2; minr = round ( min , inc ) ; if minr > min then min = minr - inc ; else min = minr ; maxr = round ( max , inc ) ; if maxr < max then max = maxr + inc ; else max = maxr ; num = ( max - min ) / inc ;

Frank Poppe PW Consulting SASŪ Software Expert Center http://www.pwcons.com

Peter Baade <Peter_Baade@HEALTH.QLD.GOV.AU> wrote in message news:s84e8255.025@health-es2.health.qld.gov.au... > I have been able to generate a workable solution to the problem below, if anyone is interested. Coding could be neater, any suggestions are always welcome. > > Thanks to Mike and Rick for their suggestions. > > Peter. >

> ************** original message ************************** > Does anyone have a formula that can be used to generate appropriate values and spacings for the y-axis on a graph. > > I am aware that SAS/GRAPH (like most graphic packages) calculated this automatically. However I am using the annotate facility to insert confidence limits, that sometimes are outside the automically generated range. All graphs have the x-axis at y=0. Therefore, if the maximum upper confidence interval is say 103, I would like the y axis to be 0 to 120 by 20. > > I thought that EXCEL and SAS must use some formula and thought someone out there might know it. > > Hope this makes sense :) > > Cheers, > > Peter > Brisbane, Australia

Back to: Top of message | Previous page | Main SAS-L page