print numbers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

print numbers

array chip
Hi,

When I plot, the axis ticks are printed as "50.00  25.00  10.00 1.00  0.05  
0.01", is there any way to print them as "50  25  10  1  0.05  0.01" instead?

Thanks

John

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

David Winsemius

On Aug 16, 2010, at 3:53 PM, array chip wrote:

> Hi,
>
> When I plot, the axis ticks are printed as "50.00  25.00  10.00  
> 1.00  0.05
> 0.01", is there any way to print them as "50  25  10  1  0.05  0.01"  
> instead?

No example, so we don't even know which of the three plotting  
paradigms you might be using, but if these are base graphics perhaps  
something along ht elines of:

   ... , labels =c("50",  "25",  "10",  "1",  "0.05",  "0.01"), ...

--
David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

array chip
sorry that I didn't give more details, thought it's going to be the same for all
plots. It's the bxp() for boxplot. I have about couple of 10 such plots in a
for() loop, so would like to automate the process. Using "labels= " certainly
works, but it's manual work - plot by plot. Any other suggestions?

Many thanks

John



----- Original Message ----
From: David Winsemius <[hidden email]>
To: array chip <[hidden email]>
Cc: R-Help <[hidden email]>
Sent: Mon, August 16, 2010 1:19:57 PM
Subject: Re: [R] print numbers


On Aug 16, 2010, at 3:53 PM, array chip wrote:

> Hi,
>
> When I plot, the axis ticks are printed as "50.00  25.00  10.00 1.00  0.05
> 0.01", is there any way to print them as "50  25  10  1  0.05  0.01" instead?

No example, so we don't even know which of the three plotting paradigms you
might be using, but if these are base graphics perhaps something along ht elines
of:

  ... , labels =c("50",  "25",  "10",  "1",  "0.05",  "0.01"), ...

--David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

David Winsemius

On Aug 16, 2010, at 4:33 PM, array chip wrote:

> sorry that I didn't give more details, thought it's going to be the  
> same for all
> plots. It's the bxp() for boxplot. I have about couple of 10 such  
> plots in a
> for() loop, so would like to automate the process. Using "labels= "  
> certainly
> works, but it's manual work - plot by plot. Any other suggestions?

?plot.default  # see examples
?axis
?format
?formatC
?sprintf

>
>
> On Aug 16, 2010, at 3:53 PM, array chip wrote:
>
>> Hi,
>>
>> When I plot, the axis ticks are printed as "50.00  25.00  10.00  
>> 1.00  0.05
>> 0.01", is there any way to print them as "50  25  10  1  0.05  
>> 0.01" instead?
>
> No example, so we don't even know which of the three plotting  
> paradigms you
> might be using, but if these are base graphics perhaps something  
> along ht elines
> of:
>
>  ... , labels =c("50",  "25",  "10",  "1",  "0.05",  "0.01"), ...
>
> --David Winsemius, MD
> West Hartford, CT
>
>
>
>

David Winsemius, MD
West Hartford, CT

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

jholtman
In reply to this post by array chip
How about this:

> x <- c(50,25,5,1,.1,.05)
> ifelse(x >= 1, sprintf("%.0f", x), sprintf("%.2f", x))
[1] "50"   "25"   "5"    "1"    "0.10" "0.05"
>


On Mon, Aug 16, 2010 at 4:33 PM, array chip <[hidden email]> wrote:

> sorry that I didn't give more details, thought it's going to be the same for all
> plots. It's the bxp() for boxplot. I have about couple of 10 such plots in a
> for() loop, so would like to automate the process. Using "labels= " certainly
> works, but it's manual work - plot by plot. Any other suggestions?
>
> Many thanks
>
> John
>
>
>
> ----- Original Message ----
> From: David Winsemius <[hidden email]>
> To: array chip <[hidden email]>
> Cc: R-Help <[hidden email]>
> Sent: Mon, August 16, 2010 1:19:57 PM
> Subject: Re: [R] print numbers
>
>
> On Aug 16, 2010, at 3:53 PM, array chip wrote:
>
>> Hi,
>>
>> When I plot, the axis ticks are printed as "50.00  25.00  10.00 1.00  0.05
>> 0.01", is there any way to print them as "50  25  10  1  0.05  0.01" instead?
>
> No example, so we don't even know which of the three plotting paradigms you
> might be using, but if these are base graphics perhaps something along ht elines
> of:
>
>  ... , labels =c("50",  "25",  "10",  "1",  "0.05",  "0.01"), ...
>
> --David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



--
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

Henrique Dallazuanna
In reply to this post by array chip
Try this:

x <- c(50,25,5,1,.1,.05)
prettyNum(x)

On Mon, Aug 16, 2010 at 4:53 PM, array chip <[hidden email]> wrote:

> Hi,
>
> When I plot, the axis ticks are printed as "50.00  25.00  10.00 1.00  0.05
> 0.01", is there any way to print them as "50  25  10  1  0.05  0.01"
> instead?
>
> Thanks
>
> John
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

Wu Gong
In reply to this post by array chip
Hi John,

formatC will do your work. Hope it helps.

x <- y <- c(50.00,25.00,10.00,1.00,0.05,0.01)
plot(x,y,log = "xy",axes = F)
axis(1, x, formatC(x))
axis(2, y, formatC(y))

Regards,

Wu
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

array chip
Thank you all for the suggestions. They all worked. Now, those numbers on the
ticks are produced by default plot function "bxp()", i.e. they are different in
each plot, is there any functions I can retrieve them so I can use formatC() or
prettyNum() etc?

Thanks again,

John



----- Original Message ----
From: Wu Gong <[hidden email]>
To: [hidden email]
Sent: Mon, August 16, 2010 2:41:51 PM
Subject: Re: [R] print numbers


Hi John,

formatC will do your work. Hope it helps.

x <- y <- c(50.00,25.00,10.00,1.00,0.05,0.01)
plot(x,y,log = "xy",axes = F)
axis(1, x, formatC(x))
axis(2, y, formatC(y))

Regards,

Wu

-----
A R learner.
--
View this message in context:
http://r.789695.n4.nabble.com/print-numbers-tp2327378p2327525.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

William Dunlap

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of array chip
> Sent: Monday, August 16, 2010 2:54 PM
> To: Wu Gong; [hidden email]
> Subject: Re: [R] print numbers
>
> Thank you all for the suggestions. They all worked. Now,
> those numbers on the
> ticks are produced by default plot function "bxp()", i.e.
> they are different in
> each plot, is there any functions I can retrieve them so I
> can use formatC() or
> prettyNum() etc?

I've been curious about that also.  I've used
the kludge of calling axis with a transparent color
to get the default positions of the tick marks,
but I don't know the official way to do it:
  > plot(3^(0:5), 0:5, log="x",axes=FALSE)
  > xTicks <- axis(side=1, col.axis="#00000000")
  > xTicks
  [1]   1   2   5  10  20  50 100 200
  > axis(side=1, at=xTicks, lab=as.character(as.roman(xTicks)))

  > yTicks <- axis(side=2, col.axis="#00000000")
  > yTicks
  [1] 0 1 2 3 4 5
  > axis(side=2, at=yTicks, lab=sprintf("%02d", yTicks))

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

>
> Thanks again,
>
> John
>
>
>
> ----- Original Message ----
> From: Wu Gong <[hidden email]>
> To: [hidden email]
> Sent: Mon, August 16, 2010 2:41:51 PM
> Subject: Re: [R] print numbers
>
>
> Hi John,
>
> formatC will do your work. Hope it helps.
>
> x <- y <- c(50.00,25.00,10.00,1.00,0.05,0.01)
> plot(x,y,log = "xy",axes = F)
> axis(1, x, formatC(x))
> axis(2, y, formatC(y))
>
> Regards,
>
> Wu
>
> -----
> A R learner.
> --
> View this message in context:
> http://r.789695.n4.nabble.com/print-numbers-tp2327378p2327525.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

Marc Schwartz-3
Bill et al,

See ?axTicks


plot(3^(0:5), 0:5, log="x",axes=FALSE)


> axTicks(1)
[1]   1   2   5  10  20  50 100 200

> axTicks(2)
[1] 0 1 2 3 4 5


HTH,

Marc Schwartz


On Aug 16, 2010, at 5:17 PM, William Dunlap wrote:

>
>> -----Original Message-----
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of array chip
>> Sent: Monday, August 16, 2010 2:54 PM
>> To: Wu Gong; [hidden email]
>> Subject: Re: [R] print numbers
>>
>> Thank you all for the suggestions. They all worked. Now,
>> those numbers on the
>> ticks are produced by default plot function "bxp()", i.e.
>> they are different in
>> each plot, is there any functions I can retrieve them so I
>> can use formatC() or
>> prettyNum() etc?
>
> I've been curious about that also.  I've used
> the kludge of calling axis with a transparent color
> to get the default positions of the tick marks,
> but I don't know the official way to do it:
>> plot(3^(0:5), 0:5, log="x",axes=FALSE)
>> xTicks <- axis(side=1, col.axis="#00000000")
>> xTicks
>  [1]   1   2   5  10  20  50 100 200
>> axis(side=1, at=xTicks, lab=as.character(as.roman(xTicks)))
>
>> yTicks <- axis(side=2, col.axis="#00000000")
>> yTicks
>  [1] 0 1 2 3 4 5
>> axis(side=2, at=yTicks, lab=sprintf("%02d", yTicks))
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>>
>> Thanks again,
>>
>> John
>>
>>
>>
>> ----- Original Message ----
>> From: Wu Gong <[hidden email]>
>> To: [hidden email]
>> Sent: Mon, August 16, 2010 2:41:51 PM
>> Subject: Re: [R] print numbers
>>
>>
>> Hi John,
>>
>> formatC will do your work. Hope it helps.
>>
>> x <- y <- c(50.00,25.00,10.00,1.00,0.05,0.01)
>> plot(x,y,log = "xy",axes = F)
>> axis(1, x, formatC(x))
>> axis(2, y, formatC(y))
>>
>> Regards,
>>
>> Wu

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: print numbers

array chip
Marc, this works perfectly!

Thanks

John


----- Original Message ----
From: Marc Schwartz <[hidden email]>
To: William Dunlap <[hidden email]>
Cc: array chip <[hidden email]>; [hidden email]
Sent: Mon, August 16, 2010 3:23:33 PM
Subject: Re: [R] print numbers

Bill et al,

See ?axTicks


plot(3^(0:5), 0:5, log="x",axes=FALSE)


> axTicks(1)
[1]   1   2   5  10  20  50 100 200

> axTicks(2)
[1] 0 1 2 3 4 5


HTH,

Marc Schwartz


On Aug 16, 2010, at 5:17 PM, William Dunlap wrote:

>
>> -----Original Message-----
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of array chip
>> Sent: Monday, August 16, 2010 2:54 PM
>> To: Wu Gong; [hidden email]
>> Subject: Re: [R] print numbers
>>
>> Thank you all for the suggestions. They all worked. Now,
>> those numbers on the
>> ticks are produced by default plot function "bxp()", i.e.
>> they are different in
>> each plot, is there any functions I can retrieve them so I
>> can use formatC() or
>> prettyNum() etc?
>
> I've been curious about that also.  I've used
> the kludge of calling axis with a transparent color
> to get the default positions of the tick marks,
> but I don't know the official way to do it:
>> plot(3^(0:5), 0:5, log="x",axes=FALSE)
>> xTicks <- axis(side=1, col.axis="#00000000")
>> xTicks
>  [1]   1   2   5  10  20  50 100 200
>> axis(side=1, at=xTicks, lab=as.character(as.roman(xTicks)))
>
>> yTicks <- axis(side=2, col.axis="#00000000")
>> yTicks
>  [1] 0 1 2 3 4 5
>> axis(side=2, at=yTicks, lab=sprintf("%02d", yTicks))
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>>
>> Thanks again,
>>
>> John
>>
>>
>>
>> ----- Original Message ----
>> From: Wu Gong <[hidden email]>
>> To: [hidden email]
>> Sent: Mon, August 16, 2010 2:41:51 PM
>> Subject: Re: [R] print numbers
>>
>>
>> Hi John,
>>
>> formatC will do your work. Hope it helps.
>>
>> x <- y <- c(50.00,25.00,10.00,1.00,0.05,0.01)
>> plot(x,y,log = "xy",axes = F)
>> axis(1, x, formatC(x))
>> axis(2, y, formatC(y))
>>
>> Regards,
>>
>> Wu

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.