Hello, Robert,

see hints below.

On Tue, 21 Dec 2010, Robert Ruser wrote:

Hello,
I'm wondering how to set a value of mar ( par( mar=c(.......)) ) in
order to allow labels to be visible in barplot. Is there any relation
between the number of characters in a label and the second value of
mar? Look at my example.

x <- seq(20, 100, by=15)
ety <- rep( "Effect on treatment group", times=length(x))
barplot(x, names.arg=ety, las=1, horiz=TRUE)

Labels are not visible. But trial and error method with the second mar
argument I get what I want.

par(mar=c(3,12,2,1), cex=0.8)
barplot(x, names.arg=ety, las=1, horiz=TRUE)

I would like something like that: second.mar = max( nchar(ety) )/2

Can't help with that really, but ...

Taking the opportunity I have 2 another question:
1. Space between labels and bars is too big - how to change it to the
value of 1 character?
2. In the example above the x axis is too short. How to make R draw a
line little longer then maximum bar length. I know that I could set
xlim=c(0,max(x)) but because of main increase equals 20 and the last
value 95 it doesn't solve the problem. The increase is ok. but only
line should be longer.

You could take a look at par()'s argument mgp, but it affects both axes at the same time. I have the impression that you want more control of the style of each axis separately; axis() might than be useful, like


par( mar = c( 3, 13, 2, 1), cex = 0.8)

barplot( x, names.arg = NULL, horiz = TRUE, axes = FALSE)

axis( side = 1, at = c( seq( 0, 80, by = 20), 95))

axis( side = 2, at = 1:length(ety), line = -1, las = 1, tick = FALSE,
      labels = ety)



Hth,

Gerrit




Thank you
Robert

______________________________________________
R-help@r-project.org 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.

______________________________________________
R-help@r-project.org 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 via email to