Re: plot label help [message #10161] |
Fri, 10 October 1997 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Rick McDaniel wrote:
>
> Here's the one I wrote. It's not a thing of beauty. It works great but
> has one flaw. Instead of printing 10^0, it justs prints 10. The other
> exponents print out fine. Again any help appreciated.
>
> FUNCTION LOGTICKS, axis, index, value
>
> IF value/10.0^9 EQ 1.0 THEN n = 9
> IF value/10.0^8 EQ 1.0 THEN n = 8
> IF value/10.0^7 EQ 1.0 THEN n = 7
[cut]
This indeed looks weird! Try the following:
IDL> x = 10^(findgen(20)-8)
IDL> print,fix(alog10(x))
-8 -7 -6 -5 -4 -3 -2 -1 0
1 2 3 4 5 6 7 8 9
10 11
You can also use something like ceil(alog10(val)) in order to get
integer exponents
for values ne 10, 100, 1000, etc.
>
> RETURN, STRING(n, $
> FORMAT="('10!E',i2.0)")
> END
>
If you use format=i2 instead of i2.0, the 0 will be printed ! Also, to
improve the
look of you numbers you may want to try
return, strcompress( string(n, format="('10!E',i2)")) , /remove_all)
This eliminates the blanks in e.g. 10!E 4.
Cheers,
Martin.
------------------------------------------------------------ ------------Dr.
Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA
phone: (617)-496-8318
fax : (617)-495-9837
Please indicate name and room (186 Pierce) when sending a fax
e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ ------------
|
|
|