Re: [R] parameter las (function par / graphics) on right axis

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Tue 04 Jul 2006 - 16:46:01 EST

Paulo Barata wrote:
> Dear R users,
>
> When trying to produce a graph with a scale on the right axis,
> I came across a possible problem with graph making in R.
>
> When using plot or barplot, when the parameter las (used
> by the graphics function par) is set to 1 (axis labels always
> horizontal), labels on the right axis are cropped when they
> have more than two digits. It seems that the graphics window
> does not allow for the extra space needed when scale labels
> are horizontal and have more than two digits. Resizing the
> graphics window does not make the graphs to show correctly.
>
> Should outer regions of the graph, or figure regions, or figure
> margins be somehow redefined when las = 1?

Yes, you can specify margins with par("las" = ....). See ?par for details.

Example:
  y <- c(100,100,100,150,150,150,150)
  par(mar = c(1,1,1,4) + 0.1)
  barplot(y, ylim=c(0,200), axes=FALSE)
  box()
  axis(side=4,las=1)

Uwe Ligges

> I use R 2.3.1, running under Windows XP. My monitor is a Samsung
> SyncMaster 794MB+, resolution is 1024 x 768 pixels. (The problem
> also occurs at the lower resolution 800 x 600 pixels).
>
> Some simple examples - barplot:
>
> # right scale shows correctly, labels are vertical
> y <- c(100,100,100,150,150,150,150)
> barplot(y, ylim=c(0,200), axes=FALSE)
> box()
> axis(side=4)
>
> # the rightmost digit of (horizontal) scale labels is cropped
> y <- c(100,100,100,150,150,150,150)
> barplot(y, ylim=c(0,200), axes=FALSE)
> box()
> axis(side=4,las=1)
>
> Some simple examples - plot:
>
> # right scale shows correctly, labels are vertical
> x <- runif(25,0,2000)
> y <- runif(25,0,2000)
> plot(x,y,axes=FALSE)
> box()
> axis(side=4)
>
> # the two rightmost digits of (horizontal) scale labels are cropped
> x <- runif(25,0,2000)
> y <- runif(25,0,2000)
> plot(x,y,axes=FALSE)
> box()
> axis(side=4,las=1)
>
> Regards,
>
> Paulo Barata
>
> -------------------------------------------------------------------
> Paulo Barata
> Fundacao Oswaldo Cruz
> Rua Leopoldo Bulhoes 1480 - 8A
> 21041-210 Rio de Janeiro - RJ
> Brasil
> Fax: 55-21-2232-9218
> E-mail: pbarata@infolink.com.br
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jul 04 16:47:42 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 04 Jul 2006 - 18:15:06 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.