0
은 가정하자 나는이 같은 GROB를 생성 한 다음 wholeplot
GROB에삽입 새로운 점은
x = 1:10
y = rnorm(10)
:
require(grid)
x = 1:10
y = rnorm(10)
plotvp = plotViewport(c(5, 5, 3, 3), name='plotvp')
datavp = dataViewport(x, y, name='datavp')
datapts = pointsGrob(x, y, pch=20, size=unit(1.3, 'mm'), name='datapts')
xaxis = xaxisGrob()
yaxis = yaxisGrob()
xlab = textGrob('X Label', y=unit(-3, 'lines'), name='xlab')
ylab = textGrob('Y Label', x=unit(-3, 'lines'), rot=90, name='ylab')
plotbox = rectGrob()
dataplot = gTree(children=gList(datapts,
xaxis, yaxis,
xlab, ylab,
plotbox),
vp=datavp, name='dataplot')
wholeplot = gTree(children=gList(dataplot),
vp=plotvp, name='wholeplot')
가 지금은 포인트의 새로운 세트를 삽입 할 , 내가 어떻게 해?
x=1:10
y=rnorm(10)
datapts2 <- pointsGrob(x, y, pch=15, size=unit(1.3, 'mm'), name='datapts2')
wholeplot <- addGrob(wholeplot, datapts2)
grid.newpage()
grid.draw(wholeplot)
system('sleep 1')
datapts2 <- pointsGrob(x, y, pch=15, size=unit(1.3, 'mm'), name='datapts2')
wholeplot <- gTree(children=gList(dataplot, datapts2), vp=plotvp, name='wholeplot')
grid.newpage()
grid.draw(wholeplot)
system('sleep 1')
내가 어떤 효과를 보지 못했다 :
은 @DWin의 대답에 따르면, 나는 다음과 같은했다.
x=1:10
y=rnorm(10)
datapts2 <- pointsGrob(
x, y, default.units='native',
pch=15, size=unit(1.3, 'mm'), name='datapts2',
vp=datavp
)
wholeplot <- addGrob(wholeplot, datapts2)
grid.newpage()
grid.draw(wholeplot)
이것은 속임수를 썼는지 :
약간의 시행 착오 후, 나는 새 데이터 포인트를 뷰포트를 지정해야합니다 깨달았다.
네 번째 라인에는'wholeplot <- addGrob (wholeplot, datapts2)'이어야합니다. 코드는 오류없이 실행되지만'grid.draw (wholeplot) '의 결과는 이전과 차이가 없습니다. – qed