comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: how to label minor tick marks on a log axis???
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: how to label minor tick marks on a log axis??? [message #24076] Fri, 09 March 2001 09:02 Go to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Paul van Delst (paul.vandelst@noaa.gov) is still ranting when
he writes:

> Yeah, well, I put use of the POSITION keyword in the same bucket as the rest of the above.
> The last thing I want to do is to have to position multiple plots on the page separately
> simply to make the y-axis label readable.

I think we could probably both agree that aesthetics is
not really RSI's thing. :-)

Cheers,

David

P.S. Let's just say that like any good spiritual practice,
IDL has its high and low moments.

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: how to label minor tick marks on a log axis??? [message #24078 is a reply to message #24076] Fri, 09 March 2001 08:01 Go to previous messageGo to next message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
David Fanning wrote:
>
> Paul van Delst (paul.vandelst@noaa.gov) writes:
>
>> Thanks, this is exactly what I wanted. Unfortunately my joy was short-lived when I
>> couldn't figure out how to shift the y-axis title over enough not to overwrite my new
>> fancy tick labels. Sigh. (Or, how come there's no X|Y|ZTITLE_OFFSET keyword to PLOT to
>> account for X|Y|ZTICKFORMAT='(a1)'?) Do you (or Martin?) have something in your
>> bag-o-tricks to do this? I looked at Martin's and your IDL webpage but didn't see
>> anything. The thought of having to futz about with CONVERT_COORD and XYOUTS to allow
>> simple shifting of an axis title makes me want to ....1.2.3.4.5....10 I better go and get
>> some coffee.
>
> Uh, normally we position the plot in the window with
> the POSITION keyword. :-)

Yeah, well, I put use of the POSITION keyword in the same bucket as the rest of the above.
The last thing I want to do is to have to position multiple plots on the page separately
simply to make the y-axis label readable.

>> I think the curmudgeon factor that Craig Markwardt has mentioned in the past is starting
>> to affect me.... :o(
>
> Probably. :-)

Definitely.


> You might be happy to know that Martin and I will soon be
> releasing some software (for free!) that might make all of
> this easier. We have a PlotConfig program that is similar
> to PSConfig. It allows the user to configure plot options
> without having to muck around with keywords.

I don't mind keywords - in fact I prefer them to GUI's. The less my fingers have to move
from the keyboard, the better my right elbow likes it. It's when there isn't a keyword to
do something simple that the mucking about comes into play.

thanx again.

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.
paul.vandelst@noaa.gov Alexander Pope.
Re: how to label minor tick marks on a log axis??? [message #24080 is a reply to message #24078] Fri, 09 March 2001 08:38 Go to previous messageGo to next message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
David Fanning wrote:

> I think it will be *slightly* better than that program
> Pavel offered yesterday. :-)

David, I thought I asked you not to look at it!
Oh well. Al least, my using the condemned platform takes me off the hook
for writing poor programs. Should have put it on an FTP site, for easy
deletion, instead of attaching to the post :-(

Pavel
Re: how to label minor tick marks on a log axis??? [message #24081 is a reply to message #24078] Fri, 09 March 2001 07:37 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Paul van Delst (paul.vandelst@noaa.gov) writes:

> Thanks, this is exactly what I wanted. Unfortunately my joy was short-lived when I
> couldn't figure out how to shift the y-axis title over enough not to overwrite my new
> fancy tick labels. Sigh. (Or, how come there's no X|Y|ZTITLE_OFFSET keyword to PLOT to
> account for X|Y|ZTICKFORMAT='(a1)'?) Do you (or Martin?) have something in your
> bag-o-tricks to do this? I looked at Martin's and your IDL webpage but didn't see
> anything. The thought of having to futz about with CONVERT_COORD and XYOUTS to allow
> simple shifting of an axis title makes me want to ....1.2.3.4.5....10 I better go and get
> some coffee.

Uh, normally we position the plot in the window with
the POSITION keyword. :-)

> I think the curmudgeon factor that Craig Markwardt has mentioned in the past is starting
> to affect me.... :o(

Probably. :-)

You might be happy to know that Martin and I will soon be
releasing some software (for free!) that might make all of
this easier. We have a PlotConfig program that is similar
to PSConfig. It allows the user to configure plot options
without having to muck around with keywords.

I have to get off my kiester and write some documentation,
and then I have to block off three weeks to answer e-mail
and change everything about it at the request of people
brave enough to use it (it is an object, of course), but
I think it will be *slightly* better than that program
Pavel offered yesterday. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: how to label minor tick marks on a log axis??? [message #24083 is a reply to message #24081] Fri, 09 March 2001 07:12 Go to previous messageGo to next message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
David Fanning wrote:
>
> Paul van Delst (paul.vandelst@noaa.gov) writes:
>
>> Sorry for the twenty questions today but how does one go about labeling the minor tick
>> marks on a log axis (or a linear one for that matter)? Does such a simple thing require
>> use of XYOUTS? I've been futzing about with the X/YTICKS keywords which does the job but
>> makes the resulting axis spacings linear! MAN!
>
> Here's a copy of an old newsgroup article by Martin that
> hasn't made it to my web page yet:

David (and Martin),

Thanks, this is exactly what I wanted. Unfortunately my joy was short-lived when I
couldn't figure out how to shift the y-axis title over enough not to overwrite my new
fancy tick labels. Sigh. (Or, how come there's no X|Y|ZTITLE_OFFSET keyword to PLOT to
account for X|Y|ZTICKFORMAT='(a1)'?) Do you (or Martin?) have something in your
bag-o-tricks to do this? I looked at Martin's and your IDL webpage but didn't see
anything. The thought of having to futz about with CONVERT_COORD and XYOUTS to allow
simple shifting of an axis title makes me want to ....1.2.3.4.5....10 I better go and get
some coffee.

I think the curmudgeon factor that Craig Markwardt has mentioned in the past is starting
to affect me.... :o(

thanx again,

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.
paul.vandelst@noaa.gov Alexander Pope.
Re: how to label minor tick marks on a log axis??? [message #24094 is a reply to message #24083] Thu, 08 March 2001 15:02 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Pavel A. Romashkin (pavel.romashkin@noaa.gov) writes:

> P.S. I guess I tried to say that I wish some things were easier to do in IDL.

Yeah, I've been using it to try and improve my
backhand, and it's worthless. :-(

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: how to label minor tick marks on a log axis??? [message #24095 is a reply to message #24094] Thu, 08 March 2001 14:49 Go to previous messageGo to next message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Paul van Delst wrote:

> Sorry for the twenty questions today but how does one go about labeling the minor tick
> marks on a log axis (or a linear one for that matter)? Does such a simple thing require
> use of XYOUTS?

You could try Adobe Illustrator or Corel Draw instead of XYouts. I had a
lot more luck with it, making IDL PS files look the way I want them. It
is so easy to make, line up, distribute and place them where you need
them. Oh, maybe I should've sent this reply to some
"comp.graphics.adobe" newsgroup?

Pavel

P.S. I guess I tried to say that I wish some things were easier to do in IDL.
Re: how to label minor tick marks on a log axis??? [message #24097 is a reply to message #24095] Thu, 08 March 2001 14:50 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Paul van Delst (paul.vandelst@noaa.gov) writes:

> Sorry for the twenty questions today but how does one go about labeling the minor tick
> marks on a log axis (or a linear one for that matter)? Does such a simple thing require
> use of XYOUTS? I've been futzing about with the X/YTICKS keywords which does the job but
> makes the resulting axis spacings linear! MAN!

Here's a copy of an old newsgroup article by Martin that
hasn't made it to my web page yet:

David

Subject: log axis
From: m218003@modell3.dkrz.de (Martin.Schultz@dkrz.de)
Date: 10 Sep 1999 15:52:08 GMT

--=-=-=__nRxTCClTGsD7YuS/WxuYofYfu__=-=-=

Hi there,

until today I still wasn't completely satisfied about plotting
logarithmic axis -- I often want to label the 2's and 5's as well
as the 10's which is not THAT straightforward as it seems. I had
already written a little function LOGLEVELS.PRO which will return
"nice-looking" log levels depending on a Range input, and now I have
added a routine named AXLABEL which puts these labels out at the
right place -- please find these two attached.

Here is how it works:
; define dummy x and y
X = findgen(101)/10.-4
Y = X > .1

; get range of data
mind = MIN(Y,MAX=maxd)
Lblv = LOGLEVELS([mind,maxd]) ; <====== 1 =====
PLOT,X,Y,/YLOG,YTICKFORMAT='(A1)'
AXLABEL,Lblv,charsize=2.4 ; ,format='exponent' ; <=== 2 ====

You could also relabel the x axis as follows:
PLOT,X,Y,/YLOG,YTICKFORMAT='(A1)',XTICKFORMAT='(A1)',XTICK_G ET=xt
AXLABEL,Lblv,charsize=2.4 ; ,format='exponent' ; <=== 2 ====
AXLABEL,xt,charsize=xc,format='(i12)',/XAxis ; <=== 2 ====

The FORMAT keyword accepts a function name similar to XTICKFORMAT, so
you can use e.g. Stein Vidar's EXPONENT function (which you can find
in David Fanning's web universe).


Thought I'd like to share this with you,
best regards,
Martin

--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 441787 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[

--=-=-=__nRxTCClTGsD7YuS/WxuYofYfu__=-=-=
Content-Type: text/plain
Content-Disposition: attachment; filename="axlabel.pro"

;----------------------------------------------------------- --
; $Id$
;+
; NAME:
; AXLABEL
;
; PURPOSE:
; Put previously calculated axis labels onto the screen
; at proper position. This routine was designed to work
; together with LOGLEVELS to produce fancy log plots.
; It involves several coordinate transformations in order
; to be device independent and take into account the
; character size. The user can specify a label format
; and use 'external' formatting functions similar to
; the [XYZ]TICKFORMAT keyword of PLOT.
;
; CATEGORY:
; Plotting
;
; CALLING SEQUENCE:
; AXLABEL,Value [,/XAxis] [,keywords]
;
; INPUTS:
; VALUE -> A vector with the values to be labelled on the
; axis.
;
; KEYWORD PARAMETERS:
; /XAxis -> If set, the labels are placed on the X achis
; rather than on the Y axis
;
; /YAxis -> Place the labels on the Y axis (this is the default,
; and this keyword is there for purely aesthetic reasons)
;
; CHARSIZE -> The character size of the label
;
; FORMAT -> An IDL format string (used as argument to the
; STRING function) or the name of a function that returns
; formatted labels. This function must accept three
; arguments, the third of which is the current value
; (see the online help to [XYZ]TICKFORMAT for more details).
; AXLABEL always passes 0 to the first two arguments.
;
; _EXTRA keywords are passed on to XYOUTS (e.g. COLOR or
; ORIENTATION). Note that the ALIGN keyword value is
; determined automatically.
;
; OUTPUTS:
; Axis labels without fuss.
;
; SUBROUTINES:
; None.
;
; REQUIREMENTS:
; A DATA coordinate system must be established by a previous
; PLOT command.
;
; NOTES:
; AXLABEL currently operates only on the left and bottom axes.
;
; EXAMPLE:
;
; MODIFICATION HISTORY:
; mgs, 10 Sep 1999: VERSION 1.00
;
;-
; Copyright (C) 1999, Martin Schultz, Max-Planck-Institut f. Meteorologie
; This software is provided as is without any warranty
; whatsoever. It may be freely used, copied or distributed
; for non-commercial purposes. This copyright notice must be
; kept with any copy of this software. If this software shall
; be used commercially or sold as part of a larger package,
; please contact the author.
; Bugs and comments should be directed to martin.schultz@dkrz.de
; with subject "IDL routine axlabel"
;----------------------------------------------------------- --


pro axlabel,value,Charsize=Charsize,XAxis=XAxis,YAxis=YAxis, $
Format=Format,_EXTRA=e

; Lblv = LOGLEVELS([mind,maxd])
; PLOT,X,Y,/YLOG,YTICKFORMAT='(A1)'

; Error catching
if (N_Elements(VALUE) eq 0) then begin
message,'Must supply a label value to AXLABEL!'
endif

; Set default for CHARSIZE and FORMAT
if (n_elements(CHARSIZE) EQ 0) then $
CHARSIZE = 1.
if (n_elements(FORMAT) EQ 0) then $
FORMAT = '(f8.1)'

if (keyword_set(XAxis)) then begin

; Get y position for label
; Subtract one character size
PY = !Y.Window[0]
PYOFF = CONVERT_COORD(1,!D.Y_CH_SIZE*CHARSIZE,/DEVICE,/TO_NORMAL)
PY = PY - 1.05*PYOFF[1]
PY = REPLICATE(PY,N_Elements(VALUE))

; Convert data values to normalized x coordinates
PX = CONVERT_COORD(VALUE,REPLICATE(!Y.CRange[0],N_Elements(VALUE) ), $
/DATA,/TO_NORMAL)
PX = PX[0,*]

endif else begin ; Y axis label (default)

; Get x position for label
PX = !X.Window[0] - 0.010
PX = REPLICATE(PX,N_Elements(VALUE))

; Convert data values to normalized coordinates and
; subtract half the character size
PYOFF = CONVERT_COORD(0,!D.Y_CH_SIZE*CHARSIZE,/DEVICE,/TO_NORMAL)
PY = CONVERT_COORD(REPLICATE(!X.CRANGE[0],N_Elements(VALUE)),VALU E, $
/DATA,/TO_NORMAL)
PY = PY[1,*]-0.5*PYOFF[1]
endelse

; Format VALUE according to format string. If this string
; does not begin with '(', it is assumed that the user has passed
; a formatting function as for [XYZ]TICKFORMAT
; However, only the third (NUMBER) argument of this function is used
if (STRPOS(FORMAT,'(') ne 0) then begin
ValS = STRARR(N_Elements(VALUE))
for j=0,N_Elements(VALUE)-1 do $
ValS[j] = CALL_FUNCTION(FORMAT,0,0,VALUE[j])
endif else $ ; apply format string directly
ValS = STRING(VALUE,format=FORMAT)

ValS = STRTRIM(ValS,2)

XYOUTS,PX,PY,ValS,/NORMAL,align=1.-0.5*keyword_set(XAxis), $
charsize=CHARSIZE,_EXTRA=e

return
end


--=-=-=__nRxTCClTGsD7YuS/WxuYofYfu__=-=-=
Content-Type: text/plain
Content-Disposition: attachment; filename="loglevels.pro"

;----------------------------------------------------------- --
; $Id: loglevels.pro,v 1.2 1999/03/24 04:30:05 mgs Exp $
;+
; NAME:
; LOGLEVELS (function)
;
; PURPOSE:
; Compute default values for logarithmic axis labeling
; or contour levels. For a range from 1 to 100 these
; would be 1., 2., 5., 10., 20., 50., 100.
; If the range spans more than (usually) 3 decades, only
; decadal values will be returned unless the /FINE keyword
; is set.
;
; CATEGORY:
; Tools
;
; CALLING SEQUENCE:
; result = LOGLEVELS([range | MIN=min,MAX=max] [,/FINE] [,COARSE=dec])
;
; INPUTS:
; RANGE -> A 2-element vector with the minimum and maximum
; value to be returned. Only levels _within_ this range
; will be returned. If RANGE contains only one element,
; this is interpreted as MAX and MIN will be assumed as
; 3 decades smaller. RANGE superseeds the MIN and MAX
; keywords. Note that RANGE must be positive definite
; but can be given in descending order in which case
; the labels will be reversed.
;
; KEYWORD PARAMETERS:
; MIN, MAX -> alternative way of specifying a RANGE. If only
; one keyword is given, the other one is computed as
; 3 decades smaller/larger than the given parameter.
; RANGE superseeds MIN and MAX.
;
; /FINE -> always return finer levels (1,2,5,...)
;
; COARSE -> the maximum number of decades for which LOGLEVELS
; shall return fine labels. Default is 3. (non-integer
; values are possible).
;
; OUTPUTS:
; A vector with "round" logarithmic values within the given
; range. The original (or modified) RANGE will be returned
; unchanged if RANGE does not span at least one label interval.
; The result will always contain at least two elements.
;
;
; SUBROUTINES:
; none
;
; REQUIREMENTS:
; none
;
; NOTES:
; If COARSE is lt 0, the nearest decades will be returned
; instead. The result will always have at least two elements.
; If COARSE forces decades, the result values may be out-of-
; range if RANGE spans less than a decade.
;
; Caution with type conversion from FLOAT to DOUBLE !!
;
; EXAMPLE:
; range = [ min(data), max(data) ]
; c_level = LOGLEVELS(range)
; contour,...,c_level=c_level
;
;
; MODIFICATION HISTORY:
; mgs, 17 Mar 1999: VERSION 1.00
;
;-
; Copyright (C) 1999, Martin Schultz, Harvard University
; This software is provided as is without any warranty
; whatsoever. It may be freely used, copied or distributed
; for non-commercial purposes. This copyright notice must be
; kept with any copy of this software. If this software shall
; be used commercially or sold as part of a larger package,
; please contact the author to arrange payment.
; Bugs and comments should be directed to mgs@io.harvard.edu
; with subject "IDL routine loglevels"
;----------------------------------------------------------- --


function loglevels,range,min=mind,max=maxd, $
coarse=coarse,fine=fine


if (n_elements(COARSE) eq 0) then COARSE = 3

; Make sure to have a valid range which is positive definite
; NOTE that range does not need to be sorted!
if (n_elements(mind) gt 0) then begin
mind = mind[0]
if (n_elements(maxd) eq 0) then maxd = mind*1000.
endif
if (n_elements(maxd) gt 0) then begin
maxd = maxd[0]
if (n_elements(mind) eq 0) then mind = maxd*0.001
endif
; still not defined, I.e. neither mind nor maxd given
if (n_elements(mind) eq 0) then begin
mind = 0.1
maxd = 100.
endif
; RANGE superseeds min and max
if (n_elements(range) eq 0) then range = [ mind,maxd ]
; one element for RANGE is interpreted as MAX
if (n_elements(range) eq 1) then range = [ range*0.001, range ]

thisrange = double(range) > 1.D-100
thisrange = thisrange(sort(thisrange))

; set lower range to 3 decades below upper range if it is zero
if (thisrange[0] lt 1.D-36) then thisrange[0] = thisrange[1]/1000.


; get log of ranges and decadal log
lrange = alog10(thisrange)
if (lrange[0] lt 0.) then lrange[0] = lrange[0] - 1.0D-6
if (lrange[1] lt 0.) then lrange[1] = lrange[1] - 1.0D-6
; if (lrange[1] gt 0.) then lrange[1] = lrange[1] + 1.0D-6
drange = fix(lrange)


; create label arrays to choose from
; currently 1.D-15 to 5.D+16
; ranges outside these limits always return only decades

; set mode according to following rules:
; - range outside limits -> return decades
; - coarse exceeded -> return decades
; - /fine set -> return 1,2,5,... for any number of decades
; - [automatic] -> return decades if more than COARSE decades
; otherwise 1,2,5,..

mode = 0 ; return decades
if (keyword_set(fine)) then mode = 1
if ((lrange[1]-lrange[0]) le COARSE) then mode = 1
if (thisrange[0] lt 1.D-15 OR thisrange[1] gt 5.D16) then mode = 0

if (mode) then begin
; make overall array
labels = [ 1.D-15, 2.D-15, 5.D-15, 1.D-14, 2.D-14, 5.D-14, $
1.D-13, 2.D-13, 5.D-13, 1.D-12, 2.D-12, 5.D-12, $
1.D-11, 2.D-11, 5.D-11, 1.D-10, 2.D-10, 5.D-10, $
1.D-09, 2.D-09, 5.D-09, 1.D-08, 2.D-08, 5.D-08, $
1.D-07, 2.D-07, 5.D-07, 1.D-06, 2.D-06, 5.D-06, $
1.D-05, 2.D-05, 5.D-05, 1.D-04, 2.D-04, 5.D-04, $
1.D-03, 2.D-03, 5.D-03, 1.D-02, 2.D-02, 5.D-02, $
1.D-01, 2.D-01, 5.D-01, 1.D+00, 2.D+00, 5.D+00 ]
labels = [ labels, $
1.D+01, 2.D+01, 5.D+01, 1.D+02, 2.D+02, 5.D+02, $
1.D+03, 2.D+03, 5.D+03, 1.D+04, 2.D+04, 5.D+04, $
1.D+05, 2.D+05, 5.D+05, 1.D+06, 2.D+06, 5.D+06, $
1.D+07, 2.D+07, 5.D+07, 1.D+08, 2.D+08, 5.D+08, $
1.D+09, 2.D+09, 5.D+09, 1.D+10, 2.D+10, 5.D+10, $
1.D+11, 2.D+11, 5.D+11, 1.D+12, 2.D+12, 5.D+12, $
1.D+13, 2.D+13, 5.D+13, 1.D+14, 2.D+14, 5.D+14, $
1.D+15, 2.D+15, 5.D+15, 1.D+16, 2.D+16, 5.D+16 ]

llabels = alog10(labels)
ind = where(llabels ge lrange[0] AND llabels le lrange[1])

; if range values are too close, return original range
if (ind[0] lt 0) then return,range

; return reversed labels if range[0] gt range[1]
if (range[0] gt range[1]) then $
return,reverse(labels[min(ind):max(ind)]) $
else $
return,labels[min(ind):max(ind)]

endif else begin

if (lrange[1] lt 0.) then drange[1] = drange[1] - 1

exponent = indgen(drange[1]-drange[0]+1)+drange[0]
if (n_elements(exponent) eq 1) then $
exponent = [ exponent, exponent+1 ]

if (range[0] gt range[1]) then $
return,reverse(10.D0^exponent) $
else $
return,10.D0^exponent
endelse

end
Re: how to label minor tick marks on a log axis??? [message #24137 is a reply to message #24083] Tue, 13 March 2001 12:05 Go to previous message
robert.m.candey.1[2] is currently offline  robert.m.candey.1[2]
Messages: 11
Registered: May 1999
Junior Member
In article <3AA8F2D2.A614462D@noaa.gov>,
Paul van Delst <paul.vandelst@noaa.gov> wrote:

> David Fanning wrote:
>>
>> Paul van Delst (paul.vandelst@noaa.gov) writes:
>>
>>> Sorry for the twenty questions today but how does one go about labeling
>>> the minor tick marks on a log axis (or a linear one for that matter)?
>>> Does such a simple thing require use of XYOUTS?
>>> I've been futzing about with the X/YTICKS keywords which
>>> does the job but makes the resulting axis spacings linear! MAN!
>>
>> Here's a copy of an old newsgroup article by Martin that
>> hasn't made it to my web page yet:
>
> David (and Martin),
>
> Thanks, this is exactly what I wanted. Unfortunately my joy was short-lived
> when I couldn't figure out how to shift the y-axis title over enough not to overwrite
> my new fancy tick labels. Sigh. (Or, how come there's no X|Y|ZTITLE_OFFSET keyword to
> PLOT to account for X|Y|ZTICKFORMAT='(a1)'?) Do you (or Martin?) have something in
> your bag-o-tricks to do this? I looked at Martin's and your IDL webpage but didn't
> see anything. The thought of having to futz about with CONVERT_COORD and XYOUTS to
> allow simple shifting of an axis title makes me want to ....1.2.3.4.5....10 I better
> go and get some coffee.
>
> I think the curmudgeon factor that Craig Markwardt has mentioned in the past
> is starting to affect me.... :o(
>
> thanx again,
>
> paulv

One way to open the left margin for all plots using !p.multi is to set
!x.omargin=[5,0] or so. This is outside margin and adds to !x.margin.

In addition, I have a little routine for writing the titles with their
own font size and color, attached below (please send improvements). We
use Martin Schultz's code for minor ticks (see
<ftp://cdaweb.gsfc.nasa.gov/pub/CDAWlib/source/>) and I have continued
to bug RSI to add labeling minor ticks on log plots with scales less
than 2 decades or so.

Robert.M.Candey@gsfc.nasa.gov 1-301-286-6707 (286-1771 fax)
NASA Goddard Space Flight Center, Code 632
Greenbelt, MD 20771 USA <http://nssdc.gsfc.nasa.gov/personnel/rcandey/>


pro plotLabel, title, yaxis=yaxis, xaxis=xaxis, color=color, font=font, $
charsize=charsize, thickness=thickness
; Robert.M.Candey.1@gsfc.nasa.gov, 1995 June 21
; 1995 July 26, BC changed font sizing

; print label on Y axis or X axis; use instead of ytitle to get control
; over font, font size and color
; main problem is lack of knowledge of how big tick labels are
; title: text to print as title of an axis (required)
; yaxis=yaxis: 0 for left Y axis, 1 for right (default=0)
; xaxis=xaxis: 0 for bottom X axis, 1 for top (default=none)
; color=color: text character color index (default=!p.color)
; charsize=charsize: text character size (default=1.0)
; font=font: text character font (default=-1 for Hershey fonts)
; thickness=thickness: text character thickness (default=1.0)

if n_elements(color) eq 0 then color = !p.color
if n_elements(font) eq 0 then font = !p.font

ticklength = 0.0
tickLabelsize = 1.0
if n_elements(charsize) eq 0 then begin
charsize = 1.0
if !p.charsize gt 0 then charsize = !p.charsize
if !p.charsize gt 0 then tickLabelsize = !p.charsize
if !p.ticklen lt 0 then tickLength = !p.ticklen
if n_elements(xaxis) ne 0 then begin ; x axis label
if !x.charsize gt 0 then charsize = !x.charsize * charSize
if !x.charsize gt 0 then tickLabelsize = !x.charsize * tickLabelsize
if !x.ticklen lt 0 then tickLength = !x.ticklen ; override p.ticklen
endif else begin ; y axis label
if !y.charsize gt 0 then charsize = !y.charsize * charSize
if !y.charsize gt 0 then tickLabelsize = !y.charsize * tickLabelsize
if !y.ticklen lt 0 then tickLength = !y.ticklen ; override p.ticklen
endelse
endif
;if n_elements(charsize) eq 0 then charsize = 1.0

if n_elements(thickness) eq 0 then $
if !p.charthick gt 0 then thickness = !p.charthick else thickness = 1.0

if n_elements(xaxis) ne 0 then begin ; xaxis label
Xmid = (!x.window(1) - !x.window(0)) / 2. + !x.window(0)
if xaxis eq 1 then begin ; top label
ticklabelLen = 0.5 < (!y.omargin(1) + !y.margin(1)) ; characters
maxTside = (1.0 - (!d.x_ch_size * charsize * 1.1)/!d.y_size) < 1.0
Tside = (!y.window(1) + ticklength + $
(!d.y_ch_size * tickLabelsize * tickLabelLen)/!d.y_size ) < maxTside
xyouts, Xmid, Tside, title, alignment=0.5, charsize=charsize, $
orientation=0, font=font, color=color, /normal
endif else begin ; bottom label
ticklabelLen = 2.5 < (!y.omargin(0) + !y.margin(0)) ; characters
; minBside = ((!d.x_ch_size * charsize * 1.1)/!d.y_size) > 0.0
minBside = 0.01
Bside = (!y.window(0) - ticklength - $
(!d.y_ch_size * tickLabelsize * tickLabelLen)/!d.y_size ) > minBside
xyouts, Xmid, Bside, title, alignment=0.5, charsize=charsize, $
orientation=0, font=font, color=color, /normal
endelse
endif else begin ; yaxis label
Ymid = (!y.window(1) - !y.window(0)) / 2. + !y.window(0)
if n_elements(yaxis) ne 0 then if yaxis eq 1 then begin ; right label
ticklabelLen = 1.5 < (!x.omargin(1) + !x.margin(1)) ; characters
maxRside = (1.0 - (!d.y_ch_size * charsize * 1.1)/!d.x_size) < 1.0
Rside = (!x.window(1) + ticklength + $
(!d.x_ch_size * tickLabelsize * tickLabelLen)/!d.x_size ) < maxRside
xyouts, Rside, Ymid, title, alignment=0.5, charsize=charsize, $
orientation=90, font=font, color=color, /normal
; orientation=270, font=font, color=color, /normal
endif else begin ; left label
ticklabelLen = 6.5 < (!x.omargin(0) + !x.margin(0)) ; characters
minLside = ((!d.y_ch_size * charsize * 1.1)/!d.x_size) > 0.0
Lside = (!x.window(0) - ticklength - $
(!d.x_ch_size * tickLabelsize * tickLabelLen)/!d.x_size ) > minLside
xyouts, Lside, Ymid, title, alignment=0.5, charsize=charsize, $
orientation=90, font=font, color=color, /normal
endelse
endelse

return
end ; plotlabel

--
Robert.M.Candey@gsfc.nasa.gov 1-301-286-6707 (286-1771 fax)
NASA Goddard Space Flight Center, Code 632
Greenbelt MD 20771 USA <http://nssdc.gsfc.nasa.gov/personnel/rcandey/>
Re: how to label minor tick marks on a log axis??? [message #24168 is a reply to message #24080] Fri, 09 March 2001 15:43 Go to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
"Pavel A. Romashkin" wrote:
> Oh well. Al least, my using the condemned platform ...

Take heart:

http://www.rsinc.com/AppProfile/idl_Motorola.cfm

and I quote:

"The Macintosh is now our fastest platform for basic binary operations
on arrays in IDL. That is quite a statement"

Now, about that OSX command line version...

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Open file in 5.4
Next Topic: GIF compression support in ImageMagick

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 14:48:55 PDT 2025

Total time taken to generate the page: 0.48190 seconds