2014-07-17 3 views
0

나는 R에서 textplot을 사용하여 작업하려했는데 내 질문이 가능한지 확실하지 않은 상태에서 par()를 사용하여 두 개의 텍스트 플롯을 한 플롯에 배치 할 수 없습니다. 나는 페이지와이 코드를 사용하여 문제를 해결하려고 노력했다.한 플롯에서 두 개의 텍스트 플롯

내 질문은 : 동일한 플롯 내에서 두 개의 텍스트 플롯을 사용할 수 있습니까? 예를 들어, 아래 par (mfrow = c (1,1)) 시나리오에서 플롯 1은 종 길이의 텍 스트 플롯입니다. 그 음모에 두 번 textplot을 복제하고 싶다고합시다. 그게 가능하니? 이 사이트를 기반으로

: 내가 원래 아래, 플롯 내에서 두 번째 textplot을 넣어 수행 할 작업을 http://svitsrv25.epfl.ch/R-doc/library/gplots/html/textplot.html

textplot(version) 
data(iris) 
par(mfrow=c(1,1)) 
info <- sapply(split(iris$Sepal.Length, iris$Species), 
      function(x) round(c(Mean=mean(x), SD=sd(x), N=gdata::nobs(x)),2)) 

textplot(info, valign="top" ) 
title("Sepal Length by Species") 

. 인수를 위해, 그 textplot을 플롯에서 두 번 복제하십시오.

이것이 가능합니까?

감사합니다.

답변

0

어쩌면 지난 4 개월 간 알아 낸 것일지도 모르지만 어쨌든 나는 답을칩니다.

제공된 코드는 이미 필요한 것을하기위한 대부분의 방법으로, title() 및/또는 par()에 몇 가지 추가 입력을 제공하면됩니다. 즉, 제목이 title("your title", outer = TRUE)을 사용하여 두 플롯보다 위에 있도록 지정하고 par()의 옵션을 사용하여 제목 위치를 추가로 조정할 수 있습니다 (par(mfrow = c(2,1), oma = c(0,0,"top",0)) 사용). 바라기를이 질문에 대한 답변입니다.

require('gplots') 

data(iris) 

info <- sapply(split(iris$Sepal.Length, iris$Species), 
      function(x) round(c(Mean = mean(x), SD = sd(x), N = gdata::nobs(x)),2)) 

## Replace top with a numerical value to control the position of the title with respect to the 
## top of the page. 
par(mfrow = c(2,1), oma = c(0,0, top ,0)) 

textplot(info, valign = "top") 
textplot(info, valign = "top") 

title("Sepal Length by Species", outer = TRUE) 
관련 문제