user969113
user969113

Reputation: 2429

R ggplot resize plot area window

I have problems resizing the plot area. If you look at the following example you will see that the label of the x-axis "x" is out of the range of the plot window/area and therefore not visible any longer. I tried to resize the plot window/area with

dev.new(width=10, height=10)

but that does not increase the space of the white boundary outside the actual plot area. I also saved the plot as PDF hoping that the label "x" will reappear in the PDF but that's also not the case.

Is it somehow possible to increase that particular area?

library(ggplot2)
df <- data.frame(x=1:10, y=1:10) 
ggplot(df, aes(x,y)) + geom_point() + 
  opts(axis.title.x = theme_text(size = 14, hjust = 0.5, vjust = -5))

Upvotes: 4

Views: 19330

Answers (1)

smillig
smillig

Reputation: 5351

To change the size of the plotting area available for axis labels and text, you can use

opts(plot.margin = unit(c(2, 2, 2, 2), "cm"))

to specify the margin size of each side of the plot.

Upvotes: 1

Related Questions