[R] change margins or regions?!

Marc Schwartz mschwartz at medanalytics.com
Mon Jul 22 03:42:34 CEST 2002


> -----Original Message-----
> Dear guRus,
> 
> after solving serveral other probs with boxplots, my ylabs do not
appear
> correct.
> They area cut off.
> I guess I have to change the letf and right margins, but I do not know
> how.
> Here is an example:
> http://frosch.homelinux.org/tmp/plot.png
> 
> Thats the code i tried to use:
> <R-code>
> oldpar <- par()
> # changing the margins
> par(mar=c(4.1,5.1,4.1,5.1) +0.1)
> P <- boxplot(bs.s ~ geologie, data=frame34, xlab="Gew.-Prozent der
> Sand-Gehalte [%]", col="grey", main=("Boxplot der Sandgehalte im
> Einzugsgebiet Hacketal"), horizontal=T, axes=F, varwidth=T)
> segments(P$stats[3, ], 1:length(P$n)  - 0.4, P$stats[3, ],
1:length(P$n)
> + 0.4, lwd = 3, col = "black")
> box()
> par(las=2)
> axis(2, label=P$names)
> axis(4, label=P$n)
> par(las=1)
> axis(1)
> dev.off()
> par(oldpar)
> </R-code>
> 
> another possible sollution would be to change the ylabs to letters
> 1:length(P$n)
> and make a legend nearby
> (...but I dont know how to use the legend-command ;-()
> 
> Anyway, thank you for your help
> steph

Stephan,

The par(mar = ...) call that you are making is the means (one of them)
to change the size of the margins.  Look at ?par and scroll down to
"mar", which describes the use of the parameter.  The values that you
are including define the bottom, left, top and right hand sides of the
plot in that order, measured in lines of text.  Increasing the second
and fourth values will change your left and right margins, respectively.

An alternative option, if wider margins begin to compromise the
presentation of your plot, is to consider using appropriate and
meaningful abbreviations for your labels in lieu of longer text.

May I suggest that you review the Introduction to R reference which you
can access via the Help menu in R.  This goes through much of the basics
of plotting in R and I think would be helpful for you.

Also, on CRAN under Documentation, are some very good contributed
documents that review many of the plotting basics, which I think would
also be helpful for you to download and review.

I note from your code and graphic that you are using varwidth = T in the
boxplot. The median line segments that you are plotting based upon the
code that I provided earlier are not being adjusted in the plot
accordingly.  If you wish to have these lines be the same width as the
boxes, you will need to either modify the code that I provided with an
adjustment to the lengths of the segments or consider Uwe's suggestion
earlier to modify the underlying procedure.

HTH.

Marc


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list