Re: Using [XYZ]TICKFORMAT for dynamic formatting [message #66473] |
Thu, 21 May 2009 05:27  |
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 #66478 is a reply to message #66475] |
Wed, 20 May 2009 16:40   |
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   |
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 #66552 is a reply to message #66486] |
Thu, 21 May 2009 14:40   |
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 #66556 is a reply to message #66478] |
Thu, 21 May 2009 14:14   |
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  |
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.
|
|
|