;The function tick_expo can be used to make tick labels into powers of 10. ;The format of the labels is: base X 10 ^ power ;The power value is a superscript. ;The base is excluded if it is 0, 1 or -1. ;The base is a single digit if it is an integer other than 0, 1 or -1. ;The base has two decimal places if it is real and not 0, 1 or -1. ; ;Use is as follows: ; When using graphics routines such as plot, set the keyword ; [xyz]tickformat='tick_expo' ; ; For example, see what happens when you type: ; plot,[.001,.01],[.1,.001],xtickformat='tick_expo',ytickformat='tick_expo' ; ;Note: The primary reason this routine was written was to be able to label ; \xlog and \ylog axis with exponent style tick labels without base ; numbers. Other cases may not show consistency in the label format ; (ie number of digits in the base or showing a base). This is because ; there is a fundamental difficulty in the way the keyword in plot (etc) ; calls this function. The routine is called internally to plot (etc) one ; tick label at a time, therefore, this routine doesn't know the format ; of previous or future labels on the axis. (Knowing the other default ; tick labels would help one make uniform labels). ; ; Some examples of the output for this routine are as follows: ; If the default tick values are 10, 100, 200 ; you get 10^1, 10,^2, 10^3 ; If the default tick values are 0, .1, .2 ; you get 0, 10^-1, 2x10^-1 ; If the default tick values are .01223, .01478, .01514 ; you get 1.22x10^-2, 1.48x10^-2, 1.51x10^-2 ; ; A logical sequence of format for all cases is not possible with ; one program. Modification of this program may be neccessary for ; more exacting applications. Good luck! ; ;Written by BWBerger 11/12/99 function tick_expo,axis,index,value if value ne 0. then begin power=floor(alog10(abs(value))) base=value/10.^power if base eq 1 then begin spaces=0 substring='10!U' endif else begin if base eq -1 then begin spaces=1 substring='-10!U' endif else begin if base ge 0 then begin if base-floor(base) eq 0 then begin substring=strmid(strtrim(string(base),2),0,1)+'!9X!310!U' endif else begin base=round(float(string(1000.*base))/10.)/100. ;I know, this ;is wierd. But there is some internal machine inaccuracy that ;really is strange. For instance try ;print,round(100.*.001675/10.^(-3)) ;You should get 168, but you actually get 167. substring=strmid(strtrim(string(base),2),0,4)+'!9X!310!U' endelse endif else begin if base lt 0 then begin if base-ceil(base) eq 0 then begin substring=strmid(strtrim(string(base),2),0,2)+'!9/!3X10!' endif else begin base=round(float(string(1000.*base))/10.)/100. substring=strmid(strtrim(string(base),2),0,5)+'!9X!310!U' endelse endif endelse endelse endelse tcklabel=substring+strtrim(string(power),2)+'!N' endif else begin tcklabel='0' endelse return,tcklabel end