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

Home » Public Forums » archive » Re: variables in plot titles
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: variables in plot titles [message #7798] Tue, 14 January 1997 00:00
f055 is currently offline  f055
Messages: 29
Registered: April 1995
Junior Member
In article <32DA4B51.167E@gl.umbc.edu>, allen bobby <ballen1@gl.umbc.edu> writes:
-I wanted to know if it is possible to have the value of a variable in
-the title of a plot? FOr instance, say I want the value of x in the
-title, because it might change with each complilation for some reason.
-How would I do that, if it's possible.

An easy one.

IDL> i=1951
IDL> plot,data,title='A plot of data for year '+string(i,format='(I4)')

The format parameter is optional, you could just use string(i).

Tim

......................... Dr Tim Osborn . t.osborn@uea.ac.uk
.... ___/.. __ /.. /.. /. Senior Research Associate . phone:01603 592089
... /..... /. /.. /.. /.. Climatic Research Unit . fax: 01603 507784
.. /..... __/.. /.. /... School of Environmental Sciences.
. /..... /\ ... /.. /.... University of East Anglia .
____/.._/..\_..____/..... Norwich NR4 7TJ .
......................... UK .
Re: variables in plot titles [message #7800 is a reply to message #7798] Mon, 13 January 1997 00:00 Go to previous message
Andy Loughe is currently offline  Andy Loughe
Messages: 174
Registered: November 1995
Senior Member
David Fanning wrote:
>
> Bobby Allen <ballen1@gl.umbc.edu> writes:
>
>> I wanted to know if it is possible to have the value of a variable in
>> the title of a plot? For instance, say I want the value of x in the
>> title, because it might change with each complilation for some reason.
>> How would I do that, if it's possible.
>
> Try this:
>
> x = 5
> thisTitle = 'Number ' + STRTRIM(x,2)
> PLOT, FINDGEN(10), Title=thisTitle


Or more generally...

thisTitle = 'Number ' + strcompress( string(x) )

--
Andrew F. Loughe | afl@cdc.noaa.gov
University of Colorado, CIRES | http://cdc.noaa.gov/~afl
Campus Box 449 | phn:(303)492-0707 fax:(303)497-7013
Boulder, CO 80309-0449 | "If you are going to be blue, be bright
blue!"
Re: variables in plot titles [message #7805 is a reply to message #7800] Mon, 13 January 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Bobby Allen <ballen1@gl.umbc.edu> writes:

> I wanted to know if it is possible to have the value of a variable in
> the title of a plot? For instance, say I want the value of x in the
> title, because it might change with each complilation for some reason.
> How would I do that, if it's possible.

Try this:

x = 5
thisTitle = 'Number ' + STRTRIM(x,2)
PLOT, FINDGEN(10), Title=thisTitle

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
2642 Bradbury Court, Fort Collins, CO 80521
Phone: 970-221-0438 Fax: 970-221-4762
E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
-----------------------------------------------------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: reading and processing netCDF Datafiles
Next Topic: MINOR CORRECTION

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

Current Time: Wed Oct 08 20:00:56 PDT 2025

Total time taken to generate the page: 0.00818 seconds