Reputation: 105
I am trying to plot a boxplot (just a single box, i.e 1 data column) but the issue I am having is that the frame enclosing the boxplot is so big compared to the actual plot/box which is in the middle. I would like to reduce the size of the frame without reducing the size of the plotted box so that the plotted box size is relative to the frame enclosing it.
For example, in this image
you can see the box is in the middle but there is a lot of space to the left and right of the box. So is there a parameter/s to make the frame size relative to the size of the plotted box? I tried to play around with a lot of parameters by setting them as arguments in par()
function but I was not successful.
This code illustrates the problem:
x = data.frame(a = 1:15)
boxplot(x, boxlwd = 2, outwex = 0.5, boxwex = 0.2)
Upvotes: 4
Views: 22360
Reputation: 115
You can customize the plot margins using these parameters, here are margin values that work with the example. Increasing the margin size reduces the size of the plot frame.
x <- data.frame(a = 1:15)
par(mar = c(1, 19, 1, 19)) # Set margins (bottom, left, top, right)
boxplot(x, boxlwd = 2, outwex = 0.5, boxwex = 0.2)
Upvotes: 1