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

Home » Public Forums » archive » Re: Using [XYZ]TICKFORMAT for dynamic formatting
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: Using [XYZ]TICKFORMAT for dynamic formatting [message #66473] Thu, 21 May 2009 05:27 Go to next message
David Gell is currently offline  David Gell
Messages: 29
Registered: January 2009
Junior Member
On May 20, 10:14 pm, David Fanning <n...@dfanning.com> wrote:
> Mark writes:
>> You can pass a function to [XYZ]TICKFORMAT, and in this function you
>> can do anything you want, including calling the IDL function
>> FORMAT_AXIS_VALUES, which is the one that is called to format axis
>> values (that figures).
>
> How many years to you suppose you have to work with
> IDL before you know the basic things about it? :-(
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Let N be the number of years of IDL experience
Let M be the number of years required to know the basics of IDL

M = 2N + 1
Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66475 is a reply to message #66473] Wed, 20 May 2009 20:14 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark writes:

> You can pass a function to [XYZ]TICKFORMAT, and in this function you
> can do anything you want, including calling the IDL function
> FORMAT_AXIS_VALUES, which is the one that is called to format axis
> values (that figures).

How many years to you suppose you have to work with
IDL before you know the basic things about it? :-(

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66478 is a reply to message #66475] Wed, 20 May 2009 16:40 Go to previous messageGo to next message
Mark[1] is currently offline  Mark[1]
Messages: 66
Registered: February 2008
Member
On May 20, 3:09 am, Paul van Delst <paul.vande...@noaa.gov> wrote:
> The problem is that I want the format in the "lowticks" function, the "f7.3", to be the
> same as those automagically chosen by IDL in the plots where the xtickformat defaults.

You can pass a function to [XYZ]TICKFORMAT, and in this function you
can do anything you want, including calling the IDL function
FORMAT_AXIS_VALUES, which is the one that is called to format axis
values (that figures).

Actually, not quite anything you want, because the function passed to
[XYZ]TICKFORMAT function works on tick value at a time, so the number
of decimal places is likely to vary. So where IDL would show...

1.0 1.5 2.0

...FORMAT_AXIS_VALUES would give

1 1.5 2
Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66486 is a reply to message #66478] Wed, 20 May 2009 05:29 Go to previous messageGo to next message
David Gell is currently offline  David Gell
Messages: 29
Registered: January 2009
Junior Member
On May 19, 10:09 am, Paul van Delst <paul.vande...@noaa.gov> wrote:
> Hello,
>
> Given the following xtickformat function,
>
>    FUNCTION lowticks, axis, index, value
>      RETURN, STRING( value, FORMAT = '("!C",f7.3)' )
>    END
>
> I am doing something like the following to get the x-axis tick labels on every other plot
> printed on the next line:
>
>    !P.MULTI = [0,n_xplots,1]
>    !X.OMARGIN = [10,3]
>    !X.MARGIN  = [0,0]
>    !Y.OMARGIN = [2,0]
>    !Y.MARGIN  = [4,2]
>
>    FOR i = 0, n_xplots-1 DO BEGIN
>      IF ( i EQ 1 OR i EQ 3 ) THEN BEGIN
>        xtickformat = 'lowticks'
>      ENDIF ELSE BEGIN
>        xtickformat = ''
>      ENDELSE
>
>      PLOT, x, y, XTICKFORMAT = xtickformat
>
>      ...etc...
>
> to prevent the end-of-axis tick labels from adjacent plots overwriting each other.
>
> The problem is that I want the format in the "lowticks" function, the "f7.3", to be the
> same as those automagically chosen by IDL in the plots where the xtickformat defaults.
>
> Does anyone know if there is any way to dynamically set the format string itself in this
> fashion? I.e. pass in the "f7.3" (or f4.1 or f5.2 etc) ?
>
> cheers,
>
> paulv

I usually do something like the following when I have to pass data to
a callback routine.
Change the lowticks routine as follows:


FUNCTION lowticks, axis, index, value, format=format
common qqlowticks, sFormat
if n_elements(sFormat) eq 0 then sFormat='("!C",f7.3)' ;;
initialize state memory
if keyword_set(format) ne 0 then begin
sFormat=format
return, 0
endif

RETURN, STRING( value, FORMAT = sFormat
END

Then, prior to using lowticks as the value of the xtickformat keyword
argument, you set the
format string,

nDummy=lowticks(format='(F7.3)'

plot, ..., xtickformat=lowticks

Hope this helps.
Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66493 is a reply to message #66486] Tue, 19 May 2009 23:56 Go to previous messageGo to next message
lbnc is currently offline  lbnc
Messages: 15
Registered: January 2005
Junior Member
On 19 May, 16:09, Paul van Delst <paul.vande...@noaa.gov> wrote:

> Does anyone know if there is any way to dynamically set the format string itself in this
> fashion? I.e. pass in the "f7.3" (or f4.1 or f5.2 etc) ?

I can't think of a way to pass it directly to lowticks. But you could
work around it by defining yourself a system variable using DEFSYSV.
That way you wouldn't have to go near COMMON blocks...

Cheers
Lasse Clausen
Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66547 is a reply to message #66475] Thu, 21 May 2009 15:28 Go to previous messageGo to next message
Mark[1] is currently offline  Mark[1]
Messages: 66
Registered: February 2008
Member
On May 21, 3:14 pm, David Fanning <n...@dfanning.com> wrote:
> How many years to you suppose you have to work with
> IDL before you know the basic things about it? :-(

I saw it in the What's New document when it was introduced. That was
back in the days when I used to read them.
Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66552 is a reply to message #66486] Thu, 21 May 2009 14:40 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
David Gell wrote:
> I usually do something like the following when I have to pass data to
> a callback routine.
> Change the lowticks routine as follows:
>
>
> FUNCTION lowticks, axis, index, value, format=format
> common qqlowticks, sFormat
> if n_elements(sFormat) eq 0 then sFormat='("!C",f7.3)' ;;
> initialize state memory
> if keyword_set(format) ne 0 then begin
> sFormat=format
> return, 0
> endif
>
> RETURN, STRING( value, FORMAT = sFormat
> END
>
> Then, prior to using lowticks as the value of the xtickformat keyword
> argument, you set the
> format string,
>
> nDummy=lowticks(format='(F7.3)'
>
> plot, ..., xtickformat=lowticks
>
> Hope this helps.

Thanks David. I try to not use common blocks where possible, but I will file it away in
case I can't get the other suggestions to work.

cheers,

paulv
Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66553 is a reply to message #66493] Thu, 21 May 2009 14:38 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
lbnc@lbnc.de wrote:
> On 19 May, 16:09, Paul van Delst <paul.vande...@noaa.gov> wrote:
>
>> Does anyone know if there is any way to dynamically set the format string itself in this
>> fashion? I.e. pass in the "f7.3" (or f4.1 or f5.2 etc) ?
>
> I can't think of a way to pass it directly to lowticks. But you could
> work around it by defining yourself a system variable using DEFSYSV.
> That way you wouldn't have to go near COMMON blocks...

Thanks Lasse I will give this a go also.

cheers,

paulv
Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66556 is a reply to message #66478] Thu, 21 May 2009 14:14 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Mark wrote:
> On May 20, 3:09 am, Paul van Delst <paul.vande...@noaa.gov> wrote:
>> The problem is that I want the format in the "lowticks" function, the "f7.3", to be the
>> same as those automagically chosen by IDL in the plots where the xtickformat defaults.
>
> You can pass a function to [XYZ]TICKFORMAT, and in this function you
> can do anything you want, including calling the IDL function
> FORMAT_AXIS_VALUES, which is the one that is called to format axis
> values (that figures).
>
> Actually, not quite anything you want, because the function passed to
> [XYZ]TICKFORMAT function works on tick value at a time, so the number
> of decimal places is likely to vary. So where IDL would show...
>
> 1.0 1.5 2.0
>
> ...FORMAT_AXIS_VALUES would give
>
> 1 1.5 2

Wow. Thanks Mark. I do have to paraphrase David Fannings comment though: How the heck was
I supposed to find that?!? :o)

Once my IDL help is working again (I just got my system rebuilt to use RHE5.0 and I'm
getting a boatload of "JVM terminated. Exit code=1" errors whenever I type "?" at the IDL
prompt) I will investigate using the magic FORMAT_AXIS_VALUES function.

Thanks muchly. This will solve a lot of problems.

cheers,

paulv
Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66614 is a reply to message #66552] Fri, 22 May 2009 11:42 Go to previous message
David Gell is currently offline  David Gell
Messages: 29
Registered: January 2009
Junior Member
On May 21, 4:40 pm, Paul van Delst <paul.vande...@noaa.gov> wrote:
> David Gell wrote:
>> I usually do something like the following when I have to pass data to
>> a callback routine.
>> Change the lowticks routine as follows:
>
>>    FUNCTION lowticks, axis, index, value, format=format
>>      common qqlowticks, sFormat
>>      if n_elements(sFormat) eq 0 then sFormat='("!C",f7.3)'  ;;
>> initialize state memory
>>      if keyword_set(format) ne 0 then begin
>>           sFormat=format
>>           return, 0
>>      endif
>
>>      RETURN, STRING( value, FORMAT = sFormat
>>    END
>
>> Then, prior to using lowticks as the value of the xtickformat keyword
>> argument, you set the
>> format string,
>
>>     nDummy=lowticks(format='(F7.3)'
>
>>     plot, ..., xtickformat=lowticks
>
>> Hope this helps.
>
> Thanks David. I try to not use common blocks where possible, but I will file it away in
> case I can't get the other suggestions to work.
>
> cheers,
>
> paulv

I also avoid common blocks for communications between routines, but I
often use them to hold state information between invocations of a
routine. Think of it as half-ass*d object programming.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Transporting code from one mac to another: Problem connection to X windows server...
Next Topic: New Business Venture

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

Current Time: Wed Oct 08 15:17:54 PDT 2025

Total time taken to generate the page: 0.01058 seconds