[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to do polar plots with logarithmic axis in radial coordinate?
Charlie Zender wrote:
>
> Craig Markwardt wrote:
>
> > Could you simply take the ALOG10() logarithm of the data before
> > plotting it? Easier to re-label the axis than re-invent the world...
> >
>
> This would cause the radial coordinate to be negative-valued which
> would have unpleasant results. It's possible someone could get
> this method to work but I tried without success.
I did the following:
IDL> r=10.0^(findgen(100)/20.0)
IDL> theta=findgen(100)/5.
IDL> !p.charsize=2.5
IDL> plot, alog10(r), theta, xsty=4,ysty=4,/polar
IDL> axis,0,0,xax=0,xtickformat='expticks_log'
% Compiled module: EXPTICKS_LOG.
IDL> axis,0,0,yax=0,ytickformat='expticks_log'
where the expticks_log.pro is:
FUNCTION expticks_log, axis, index, value
tickmark = '10!E' + $
STRTRIM(STRING(value,FORMAT='(f5.1)'),2) + $
'!N'
RETURN, tickmark
END
The !P.CHARSIZE was just so I could see the exponents. Is this what you are looking for?
Keep in mind that the format string for the expticks_log.pro won't work for exponents less
than 0.0 - you'll have to get smart about checking for the range and then setting the
format string based on that (rather than the f5.1 above, e.g.:
CASE 1 OF
; -- Exponent is less than zero ->
; -- fractional ticklabel
( exponent LT 0 ): format = '( f' + $
STRTRIM(ABS(exponent)+2,2) + $
'.' + $
STRTRIM(ABS(exponent),2) + $
' )'
; -- Exponent is greater than or = to zero ->
; -- whole number ticklabel
( exponent GE 0 ): format = '( i' + $
STRTRIM(ABS(exponent)+1,2) + $
' )'
ENDCASE
and then use the format string in the return value, e.g.
RETURN, '10!E' + STRING( value, FORMAT = format ) + '!N'
or something similar depending on your tastes/needs.
Hope some of this is helpful, although I have to admit, the fact that IDL doesn't have a
stock polar plotting routine that produces a circular graph with the radial and concentric
circle tickmark axes is a bit ridiculous. Farting about with /POLAR and AXIS and whatnot
is sort of like using OG to plot, x, y - and in the end you still end up with
Cartesian-like axes.
Maybe there is a polar plotting routine out there in IDL software land somewhere. It is
sorely needed.
paulv
--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
pvandelst@ncep.noaa.gov Alexander Pope.