[R] About graphics
Duncan Murdoch
murdoch at stats.uwo.ca
Fri Feb 5 16:57:58 CET 2010
On 05/02/2010 10:48 AM, Silvano wrote:
> Hi,
>
> I'm building a graph (barplot) in which the X axis label
> disappears.
> I tried to use the option mgp of par() and I could not get
> the desired result.
>
> Note that want the axis labels horizontally.
>
> caes = c(37,20,19,16,75,103)
> names(caes) = c("Pinscher", "Pastor \n Alemão", "Poodle",
> "Rottweiller", "SRD", "Outros")
> caess = sort(caes, decreasing=F)
> par(mar=c(3, 5.7, 1, 1), mgp=c(4.5, .5, 0), las=1)
>
You've set margin 1 too small. The barplot() function puts the x axis
label quite far from the plot, so you need something like
par(mar=c(6.1, 5.7, 1, 1), mgp=c(4.5, .5, 0), las=1)
to give room for it. I think it would look better with the label
closer, which you can do using
mtext("Frequências", side=1, line=3)
(and this would work with a smaller margin, but not as small as 3). For
example,
caes = c(37,20,19,16,75,103)
names(caes) = c("Pinscher", "Pastor \n Alemão", "Poodle",
"Rottweiller", "SRD", "Outros")
caess = sort(caes, decreasing=F)
par(mar=c(4.5, 5.7, 1, 1), mgp=c(4.5, .5, 0), las=1)
barplot(caess, cex.axis=1, cex.names=1, ylab="Raças dos Cães",
xlab="", bty='l', col="LightYellow",
horiz=T, xlim=c(0,120))
mtext("Frequências",side=1, line=3)
abline(v=0)
> barplot(caess, cex.axis=1, cex.names=1, ylab="Raças dos
> Cães",
> xlab="Frequências", bty='l', col="LightYellow",
> horiz=T, xlim=c(0,120))
> abline(v=0)
>
> Suggestions?
>
> --------------------------------------
> Silvano Cesar da Costa
> Departamento de Estatística
> Universidade Estadual de Londrina
> Fone: 3371-4346
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list