Adjust Plot Size in R: Step-by-Step Guide

In R language, you can adjust the size of a plot using the par() function. Here is how you can do it:

# 设置plot的大小为宽度为4英寸,高度为3英寸
par(pin=c(4,3))

# 绘制plot
plot(x, y)

# 恢复默认设置
par(pin=c(7, 7))

The pin parameter in the function can control the size of the drawing area, with the first value representing width and the second value representing height. Adjusting the size by setting the pin parameter in the par() function can change the plot size. It is important to note that after adjusting the size, use the par() function to restore the default settings to avoid affecting future drawings.

bannerAds