Re: IDLgrAxis set TICKVALUES in specific positions [message #61422] |
Thu, 17 July 2008 09:59  |
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   |
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
|
|
|
|
|