Reputation: 742
I would like to create two plots side-by-side, but the problem I am running into is that R seemingly can not enlarge the "plotting space", which results in shrinkage of both graphs on the x-axis like so:
You can also see that the line names also get cropped due to not enough space being present. Sow the question is: how do I make the plots wider and the labels fully visible? It would be great to avoid any libraries like ggplot
, but if there is no other way, this will be fine as well.
Here is how the plots above are constructed:
layout(matrix(c(1,2), 1, 2, byrow = TRUE))
plot(plot1)
plot(plot2) # axis(4, at = coef1[nrow(coef1), ], labels = colnames(coef1), cex = 0.8, adj = 0, las=2)
Upvotes: 1
Views: 18030
Reputation: 13
If you are working inside a Jupiter notebook, I found the answer on this link: https://blog.revolutionanalytics.com/2015/09/resizing-plots-in-the-r-kernel-for-jupyter-notebooks.html
library(repr)
library(ISLR)
options(repr.plot.width=20, repr.plot.height=20)
pairs(Auto)
Upvotes: 0
Reputation: 76402
You can open a graphics device, such as x11()
, windows()
or cairo()
setting the width and height. This will automatically resize the plot regions. In the example that follows, making them larger.
x11(width = 20, height = 4)
layout(matrix(c(1,2), 1, 2, byrow = TRUE))
plot(1:10)
plot(-(1:10))
As for the margins, see help("par")
, entries for oma
and mar
.
Upvotes: 2