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

Home » Public Forums » archive » Re: xyouts: define decimal places of variable
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: xyouts: define decimal places of variable [message #65234] Thu, 19 February 2009 19:43
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark writes:

> On Feb 19, 12:35=A0am, Carsten Lechte <c...@toppoint.de> wrote:
>> Use the STRING function, which does accept format statements:
>>
>> XYOUTS, 0.5, 0.5, STRING( 0.3453534534, FORMAT=3D'(F6.2)')
>
> A minor addition: you can omit the leading spaces with FORMAT=3D'(F0.2)'

While I am thinking about it, I always use NUMBER_FORMATTER
to format numbers into strings so I can display them in
text widgets. You can specify how many decimal places
you want in the number with a keyword.

http://www.dfanning.com/programs/number_formatter.pro

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: xyouts: define decimal places of variable [message #65236 is a reply to message #65234] Thu, 19 February 2009 13:04 Go to previous message
Mark[1] is currently offline  Mark[1]
Messages: 66
Registered: February 2008
Member
On Feb 19, 12:35 am, Carsten Lechte <c...@toppoint.de> wrote:
> Use the STRING function, which does accept format statements:
>
> XYOUTS, 0.5, 0.5, STRING( 0.3453534534, FORMAT='(F6.2)')

A minor addition: you can omit the leading spaces with FORMAT='(F0.2)'
Re: xyouts: define decimal places of variable [message #65254 is a reply to message #65236] Wed, 18 February 2009 03:35 Go to previous message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
julia.walterspiel@gmail.com wrote:
> is there a way to define the number of decimal places when plotting a
> (float) variable into a plot via xyouts?

Use the STRING function, which does accept format statements:

XYOUTS, 0.5, 0.5, STRING( 0.3453534534, FORMAT='(F6.2)')


chl
Re: xyouts: define decimal places of variable [message #65255 is a reply to message #65254] Wed, 18 February 2009 02:58 Go to previous message
julia.walterspiel is currently offline  julia.walterspiel
Messages: 35
Registered: July 2008
Member
thank you Andy, that helped!
cheers
julia
Re: xyouts: define decimal places of variable [message #65257 is a reply to message #65255] Wed, 18 February 2009 02:24 Go to previous message
Andy Heaps is currently offline  Andy Heaps
Messages: 22
Registered: March 2006
Junior Member
Hello Julia,
try the following:

xyouts, x, y, STRTRIM(STRING(myvariable, FORMAT='(f10.2)'), 2), /Normal

Cheers
Andy



julia.walterspiel@gmail.com wrote:
> hello everyone
>
> is there a way to define the number of decimal places when plotting a
> (float) variable into a plot via xyouts?
> eg
> xyouts, x, y, myvariable, /Normal
>
> --> 0.3423564 but I only want it to display 0.34
>
> i understand the FORMAT-codes do not work with xyouts...
>
> thanks for any hints,
> julia
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Interpolating/gridding field reflectance spectra
Next Topic: Re: Interpolating/gridding field reflectance spectra

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

Current Time: Wed Oct 08 11:51:13 PDT 2025

Total time taken to generate the page: 0.00534 seconds