[R] Numerical Format on axis

MacQueen, Don macqueen1 at llnl.gov
Thu Nov 17 02:30:22 CET 2011

To add to what David suggests, and since you're new to R, something like

plot(x,y, yaxt='n')
yticks <- pretty(y)
axis(2, at=yticks, labels=sprintf("%1.2f",yticks))

See the help page for par
and look for the entry for 'xaxt' to see what the 'yaxt' arg to plot does.

Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550

On 11/16/11 6:35 AM, "David Winsemius" <dwinsemius at comcast.net> wrote:

>On Nov 16, 2011, at 7:41 AM, Mario Giesel wrote:
>> Hello, list,
>>  I'm new to R and I'm trying to produce a chart with currency values
>> on the y axis.
>> Values should be e.g. 1,00, 1,50, 2,00, etc.
>> In fact they are 1,0, 1,5, 2,0, etc.
>> How do I get R to show two digits after the comma on that axis?
>On the left (geographic) side of the  Atlantic, it might be:
> > sprintf("%1.2f", 1)
>[1] "1.00"
>I assume that your system is set up with different options() and that
>your punkts are going to be handle to your liking by sprintf.
>David Winsemius, MD
>West Hartford, CT
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list