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

Home » Public Forums » archive » Re: Adding Text/Equations to Plots
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Adding Text/Equations to Plots [message #65700 is a reply to message #65698] Mon, 16 March 2009 13:16 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
Jean H. wrote:
> Heather wrote:
>
>> IDL> numbers=findgen(10)
>> IDL> string="This is a number: numbers(6)"
>> IDL> print, string
>> This is a number: numbers(6)
>
>> Any advice would be greatly appreciated, but I'm fairly new to the
>> world of IDL, so please use "simple" explanations!
>> Thanks,
>> Heather
>
> Heather,
> You can do string concatenation and conversion
>
> print, "this is a number " + string(numbers[6])
>
> you can also have more control... remove the blanks:
>
> print, "this is a number " + strtrim(numbers[6],2)
>
> or even add formats:
> print, "this is a number " + string(numbers[6],format = '(I)')
>
> and with no blanks
>
> print, "this is a number " + strtrim(string(numbers[6],format = '(I)'),2)
>
> Jean
> PS: replace print, by text = if you want to save the string

I have been steering away from string concatenation and using C format
strings for almost everything lately:

IDL> print, numbers[6], format='(%"This is a number: %f.")'

I think the code is a more readable. Of course, then you have to learn
the available format codes (with C and Fortran versions to choose from).

The STRING command accept the same FORMAT if you want to pass the string
to a keyword of XYOUTS, PLOT, etc.

By the way, I hate that I have to type five extra characters to get
C-style format codes. Maybe a cformat option to COMPILE_OPT to switch
the default format to C-style? (Yes, I know "cformat" is seven characters.)

Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Adding Text/Equations to Plots
Next Topic: Using contour in postscripts produces a "stripe" effect?

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

Current Time: Sat Oct 11 07:49:46 PDT 2025

Total time taken to generate the page: 0.40266 seconds