Daniel Valencia C.
Daniel Valencia C.

Reputation: 2279

How to set axis length in R

I'm new using R, so I want to know if there is a way to set the axis length to a fixed value like 5 cm.

par(pty="s")
a1=c(22.02, 23.83,  26.67,  25.38,  25.49,  23.50,  25.90,  24.89)
a2=c(21.49, 22.67,  24.62,  24.18,  22.78,  22.56,  24.46,  23.79)
a3=c(20.33, 21.67,  24.67,  22.45,  22.29,  21.95,  20.49,  21.81)
boxplot(a1,a2,a3, las=1)

I'm getting

enter image description here

Is ther a way to set the axis length to a fixed value??

EDIT 1

I want something like this (sorry for the quality)

enter image description here

Upvotes: 0

Views: 2087

Answers (1)

Łukasz Deryło
Łukasz Deryło

Reputation: 1860

First you may set up graphics window dimensions with win.graph. E.g. default

win.graph(7,7)

gives you 7 inch x 7 inch graphics window.

Then you set up outer margins (in inches also):

par(mai=c(2,2,2,2))

Numbers inside c() are bottom, left, top and right margin widths (in inches).

So

win.graph(7,7)
par(mar=c(2,2,2,2))

leaves 5 inch x 5 inch square for the plot. You just need to convert inches to cm and choose arguments for win.graph to cover your axis labels.

Upvotes: 1

Related Questions