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

Home » Public Forums » archive » Re: IDLgrAxis set TICKVALUES in specific positions
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: IDLgrAxis set TICKVALUES in specific positions [message #61422] Thu, 17 July 2008 09:59 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
bernat writes:

> I tried it with no results. EXAMPLE:
>
> values=['0','30','50','70']
> values_pos=['50','55','76','256']
> text_arr=objarr(n_elements(values))
> for i=0, n_elements(values)-1 do begin
> itext=OBJ_NEW('IDLgrText', values[i], FONT=self.font, $
> RECOMPUTE_DIMENSIONS=2, /ENABLE_FORMATTING)
> text_arr[i]=itext
> endfor
>
> ;-- then the axis
>
> axis=OBJ_NEW('IDLgrAxis', 1, TEXTPOS=1, TICKDIR=0, $
> TICKTEXT=text_arr, /EXACT, MAJOR=N_ELEMENTS(values), MINOR=0,
> TICKLEN=3)
>
> axis->GetProperty, TICKTEXT=ticktext, YCOORD_CONV=ys
> for i=0, n_elements(ticktext)-1 do begin
> location=[ys[0], (values_pos[i]/256.)*ys[1]]
> ticktext[i]->SetProperty, LOCATION=location
> endfor
>
> xobjview, axis

The thing about object graphics that makes it so much fun
to work with, is that there are thousands of ways to do
something incorrectly and one one way (usually) to do it
right. And the best part is: YOU GET NO FEEDBACK!!! :-)

Try this:

values=['0','30','50','70']
values_pos=['50','55','76','256']
text_arr=objarr(n_elements(values))
for I=0, n_elements(values)-1 do begin
itext=OBJ_NEW('IDLgrText', values_pos[I], $
RECOMPUTE_DIMENSIONS=2, /ENABLE_FORMATTING)
text_arr[I]=itext
endfor

;-- then the axis

axis=OBJ_NEW('IDLgrAxis', 1, TEXTPOS=1, TICKDIR=0, $
TICKTEXT=text_arr, /EXACT, MAJOR=N_ELEMENTS(values), MINOR=0,$
TICKLEN=3, TICKVALUES=values_pos/256.)

axis->GetProperty, TICKTEXT=ticktext, YCOORD_CONV=ys
for I=0, n_elements(ticktext)-1 do begin
location=[ys[0], (values_pos[I]/256.)*ys[1]]
ticktext[I]->SetProperty, LOCATION=location
endfor

xobjview, axis

END
--
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: IDLgrAxis set TICKVALUES in specific positions [message #61424 is a reply to message #61422] Thu, 17 July 2008 09:32 Go to previous messageGo to next message
natha is currently offline  natha
Messages: 482
Registered: October 2007
Senior Member
On Jul 17, 11:39 am, David Fanning <n...@dfanning.com> wrote:

> I think you would get the text object from your axis with
> the TICKTEXT keyword, then set the LOCATIONS of the strings.
>

I tried it with no results. EXAMPLE:

values=['0','30','50','70']
values_pos=['50','55','76','256']
text_arr=objarr(n_elements(values))
for i=0, n_elements(values)-1 do begin
itext=OBJ_NEW('IDLgrText', values[i], FONT=self.font, $
RECOMPUTE_DIMENSIONS=2, /ENABLE_FORMATTING)
text_arr[i]=itext
endfor

;-- then the axis

axis=OBJ_NEW('IDLgrAxis', 1, TEXTPOS=1, TICKDIR=0, $
TICKTEXT=text_arr, /EXACT, MAJOR=N_ELEMENTS(values), MINOR=0,
TICKLEN=3)

axis->GetProperty, TICKTEXT=ticktext, YCOORD_CONV=ys
for i=0, n_elements(ticktext)-1 do begin
location=[ys[0], (values_pos[i]/256.)*ys[1]]
ticktext[i]->SetProperty, LOCATION=location
endfor

xobjview, axis
Re: IDLgrAxis set TICKVALUES in specific positions [message #61432 is a reply to message #61424] Thu, 17 July 2008 08:39 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
bernat writes:

> I want to set TICKVALUES in the IDLgrAxis in certain specific
> positions which I would define. Is similar to TICKPOS property in
> IDLgrColorbar.
>
> How to do that ?

I think you would get the text object from your axis with
the TICKTEXT keyword, then set the LOCATIONS of the strings.

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: IDLgrAxis set TICKVALUES in specific positions [message #61519 is a reply to message #61422] Thu, 17 July 2008 10:10 Go to previous message
natha is currently offline  natha
Messages: 482
Registered: October 2007
Senior Member
:)

Only using TICKVALUES it's enough !
Then it's not necessary to do the last FOR loop to move each string in
the right position.

Thanks
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Font compatibility question
Next Topic: Re: Font compatibility question

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

Current Time: Wed Oct 08 13:53:04 PDT 2025

Total time taken to generate the page: 0.00729 seconds