Re: xyouts: define decimal places of variable [message #65234] |
Thu, 19 February 2009 19:43 |
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  |
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 #65257 is a reply to message #65255] |
Wed, 18 February 2009 02:24  |
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
|
|
|