我在R中繪製了以下繪圖。我希望在現有繪圖形式x =[0, 2]
和y=[0, 2]
中有一個子圖,我也想放大該子圖。我如何在R中做到這一點?放大現有繪圖中的子圖R
lin <- data.frame(x = c(0:6), y = c(0.3, 0.1, 0.9, 3.1, 5, 4.9, 6.2))
linm <- lm(y ~ x, data = lin, subset = 2:4)
plot(y ~ x, data = lin)
abline(linm)
我在R中繪製了以下繪圖。我希望在現有繪圖形式x =[0, 2]
和y=[0, 2]
中有一個子圖,我也想放大該子圖。我如何在R中做到這一點?放大現有繪圖中的子圖R
lin <- data.frame(x = c(0:6), y = c(0.3, 0.1, 0.9, 3.1, 5, 4.9, 6.2))
linm <- lm(y ~ x, data = lin, subset = 2:4)
plot(y ~ x, data = lin)
abline(linm)
您可以使用xlim和ylim參數更改繪圖函數的繪圖極限。例如
plot(y~x, data = lin, xlim=c(0,2), ylim=c(0,2))
比如,你可以這樣做:
lin <- data.frame(x = c(0:6), y = c(0.3, 0.1, 0.9, 3.1, 5, 4.9, 6.2))
linm <- lm(y ~ x, data = lin, subset = 2:4)
plot(y ~ x, data = lin)
abline(linm)
## to overlap the 2 plots
par(new=TRUE, oma=c(3,1,1,2))
## create a layout to plot the subplot in the right bottom corner
layout(matrix(1:4,2))
## use xlim and ylim to zoom the subplot
plot(y ~ x, data = lin,xlim=c(0,2), ylim=c(0,2))
abline(linm)
謝謝。這個子圖是可以的,但是我怎樣才能放大這個子圖或者使它變大? – rose
[相關](http://stackoverflow.com/questions/13714724/how-to-draw-a -zoom-in-effect-in-r/13728281)question,answers,comments .. – Julius
@Julius。我已經看到了這個問題,但是這個功能只是放大了這一點而不是線條。 – rose