Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Re: Using [XYZ]TICKFORMAT for dynamic formatting
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
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.
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
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.")
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
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
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
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
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.
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.