[R] plot only x- and y-axis with origin, no box()

Talloen, Willem [PRDBE] WTALLOEN at PRDBE.JNJ.COM
Wed Jun 20 10:08:22 CEST 2007


perfect Romain,
box( bty = "l", lwd = 2 )
is the solution !
thank you all for your kind responses,
willem

-----Original Message-----
From: Romain Francois [mailto:rfrancois at mango-solutions.com]
Sent: Wednesday, 20 June 2007 10:01
To: Talloen, Willem [PRDBE]
Subject: Re: [R] plot only x- and y-axis with origin, no box()


Talloen, Willem [PRDBE] wrote:
> Yes Greg,
>
> Your provided solution does the job;
>   
>> plot(5:10, 5:10, bty='n')
>> library(TeachingDemos)
>> lines(cnvrt.coords( c(0,0,.5), c(.5,0,0), input='plt')$usr)
>>     
>
> The easy way is indeed to do 
>   
>> plot(.., bty='l')
>>     
> but this cannot be used in combination with fixing tickmarks and changing width of the axes.
>
> HOWEVER, there is still a small error. The width of the added y-axis has not the same width;
>   
>> plot(5:10, 5:10,axes=F)
>> axis(1,lwd=2)
>> axis(2,lwd=2)
>> library(TeachingDemos)
>> lines(cnvrt.coords( c(0,0,.5), c(.5,0,0), input='plt')$usr,lwd=2)
>>     
Hi Willem ,

In that case, I would go with a vanilla `plot` call and then add `axis` 
and `box` low-level function calls:

plot( 5:10, 5:10, axes = FALSE  )
axis( 1, lwd = 2, .. )
axis( 2, lwd = 2, .. )
box( bty = "l", lwd = 2 )

Cheers,

Romain

> Any ideas?
> Willem
>
> -----Original Message-----
> From: Greg Snow [mailto:Greg.Snow at intermountainmail.org]
> Sent: Tuesday, 19 June 2007 18:23
> To: Talloen, Willem [PRDBE]; r-help at stat.math.ethz.ch
> Subject: RE: [R] plot only x- and y-axis with origin, no box()
>
>
>
> Try:
>
>   
>> plot(.., bty='l')
>>     
>
> Does that do what you want?  (see the bty parameter in ?par for details)
>
> If you don't want the lines extending beyond the axes on the right and
> top then you could do something more like:
>
>   
>> plot(5:10, 5:10, bty='n')
>> library(TeachingDemos)
>> lines(cnvrt.coords( c(0,0,.5), c(.5,0,0), input='plt')$usr)
>>     
>
> You may also get what you want by playing with the xaxp and yaxp
> parameters to par, but the bty='l' seems the easiest way to go. 
>
>   


-- 
Mango Solutions
data analysis that delivers

Tel:  +44(0) 1249 467 467
Fax:  +44(0) 1249 467 468
Mob:  +44(0) 7813 526 123



More information about the R-help mailing list