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

Paulo Barata pbarata at infolink.com.br
Tue Jul 4 05:24:17 CEST 2006


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?

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 at infolink.com.br



More information about the R-help mailing list