HELP !!! [message #10451] |
Wed, 03 December 1997 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Hi,
after spending more than 1 hour on this, I finally decided that this
should definitively get improved in a future release of IDL (I guess I
should put together some kind of a wishlist for the people at RSI):
problem is, I want to produce a plot with two x-axis, one on the bottom
(easy of course :-) and one on the top. The little code piece I attached
works fine *except* the title of the top axis is too low and interferes
with the axis labels. I tried several things:
- append a sequence of !C's at the end of xtitle ==> no effect at
all
- add another axis statement shifted somewhat higher and suppress
the axis itself using xstyle=4 and xticks=1 ==> title comes out
fine now, but the axis is *not* suppressed
- use a title parameter in the call to plot ==> font is larger
(hence ugly)
I browsed around the help pages for at least 1/2 hour and could not find
*anything* about this issue, so i guess that's the minimum that would
need improvement!
Here's the code:
; produce some dummy data as a demo
alt10=findgen(20)*0.6
o3=alt10*10
co=o3/2.
h2o=exp((alt10+2)/2)
co_ok=indgen(20)
!p.thick=3
!p.position = [ 0.2, 0.3, 0.8, 0.8 ]
; produce profile plot
plot,o3,alt10,/nodata,color=1,xstyle=9,xrange=[0,140], $
ystyle=1,yrange=[0,12], $
xtitle='O!L3!N, CO [ppb], C!L2!NH!L2!N [ppt]', $
ytitle='altitude [km]' ;, $
title='H!L2!NO [ppmv]!C!C'
oplot,o3,alt10,color=7,thick=4
oplot,co(co_ok),alt10(co_ok),color=2,thick=4
; overlay extra x-axis for log water vapor
axis,0.5,12,/DATA,color=1,xax=1,xstyle=1,xrange=[100,20000.] ,/xlog,$
/SAVE,xtitle='H!L2!NO [ppmv]'
oplot,h2o,alt10,color=4,thick=4
; ps: aside from this, I still think that IDL is a great language !
--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA
phone: (617)-496-8318
fax : (617)-495-4551
e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
|
|
|
Re: Help ! [message #14901 is a reply to message #10451] |
Thu, 01 April 1999 00:00  |
Ivan Zimine
Messages: 40 Registered: February 1999
|
Member |
|
|
VU KHAC Tri wrote:
>
> Hi folks,
>
> I write a procedure which reads an image when a button pressed.
>
> pro BTLoad_Event, event
> WIDGET_CONTROL, event.id, GET_UVALUE = info
> fname = DIALOG_PICKFILE(FILE = info.filename, /READ, FILTER = '*.hdr',
> $
> /MUST_EXIST, /FIX_FILTER, PATH = path, /NOCONFIRM)
> IF fname NE "" THEN BEGIN, info.image
> ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> ENDIF
> end
>
> pro Read_Analyze, File, Image
> ;it reads some data from the file and modifies some fields in Image
> end;
>
> I see that in the Read_Analyze, data is read correctly, but in
> BTLoad_Event, info.image is not modified. Anyone can tell me why ?
>
> Best regards,
> Tri.
Since, info.image is a structure de-reference it is passed to
Read_Analyze by value and not by reference (IDL Programming Techniques
p.207 :-)) which means that when you exit from Read_Analyze, info.image
is not changed.
You can do the following:
IF fname NE "" THEN BEGIN
Read_Analyze, fname, tmp
info.image=tmp
endif
WIDGET_CONTROL, event.top, SET_UVALUE=info
but i think that Read_Analyze would work better if it was a function,
then you could do
info.image=Read_Analyze(fname)
Also look at pointers to pass image data between event handlers...
cheers
--
Ivan Zimine
Dpt. of Radiology (MRI), Geneva University Hospitals
email: ivan.zimine@physics.unige.ch
tel. : (+41 22) 372 70 70
|
|
|
Re: Help ! [message #14902 is a reply to message #10451] |
Thu, 01 April 1999 00:00  |
William Daffer
Messages: 34 Registered: February 1999
|
Member |
|
|
VU KHAC Tri <tvk@info.fundp.ac.be> writes:
> Hi folks,
>
> I write a procedure which reads an image when a button pressed.
>
> pro BTLoad_Event, event
> WIDGET_CONTROL, event.id, GET_UVALUE = info
> fname = DIALOG_PICKFILE(FILE = info.filename, /READ, FILTER = '*.hdr',
> $
> /MUST_EXIST, /FIX_FILTER, PATH = path, /NOCONFIRM)
> IF fname NE "" THEN BEGIN
> Read_Analyze, fname, info.image
> ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> ENDIF
> end
>
> pro Read_Analyze, File, Image
> ;it reads some data from the file and modifies some fields in Image
> end;
>
> I see that in the Read_Analyze, data is read correctly, but in
> BTLoad_Event, info.image is not modified. Anyone can tell me why ?
>
> Best regards,
> Tri.
info.image is passed by value, or as a reference to a temporary
variable, I'm not sure which. I think if you change it in the
following manner, it'll work.
IF fname NE "" THEN BEGIN
image=info.image
Read_Analyze, fname, image
info.image =image
ENDIF
or, maybe pointers?
whd
--
My mail address has been mangled by my mailer. Send replies to...
daffer@primenet.com
--
Outside of a dog, a book is man's best friend
Inside of a dog, it's too dark to read.
Groucho Marx.
|
|
|
Re: Help ! [message #14903 is a reply to message #10451] |
Thu, 01 April 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
VU KHAC Tri (tvk@info.fundp.ac.be) writes:
> I write a procedure which reads an image when a button pressed.
>
> pro BTLoad_Event, event
> WIDGET_CONTROL, event.id, GET_UVALUE = info
> fname = DIALOG_PICKFILE(FILE = info.filename, /READ, FILTER = '*.hdr',
> $
> /MUST_EXIST, /FIX_FILTER, PATH = path, /NOCONFIRM)
> IF fname NE "" THEN BEGIN
> Read_Analyze, fname, info.image
> ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> ENDIF
> end
>
> pro Read_Analyze, File, Image
> ;it reads some data from the file and modifies some fields in Image
> end;
>
> I see that in the Read_Analyze, data is read correctly, but in
> BTLoad_Event, info.image is not modified. Anyone can tell me why ?
Because info is a LOCAL variable in this procedure. (You
copied the information in the User Value of the top-level
base into the LOCAL variable info.) If you make changes,
you have to be sure to put it back in the UVALUE before
you exit the event handler:
WIDGET_CONTROL, event.id, SET_UVALUE = info
END;
I still have two cheap IDL Programming books left.
Lot's of information about widget programming there. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|