Programing

plot.new () 오류 : R에서 그림 여백이 너무 큽니다.

lottogame 2020. 8. 12. 22:10
반응형

plot.new () 오류 : R에서 그림 여백이 너무 큽니다.


저는 R을 처음 접했지만 더 작은 데이터 세트로 수많은 상관 관계 플롯을 만들었습니다. 그러나 대규모 데이터 세트 (2GB +)를 플롯하려고하면 플롯을 잘 생성 할 수 있지만 범례가 표시되지 않습니다. 어떤 충고? 또는 대안?

library(gplots)
r.cor <- cor(r)
layout(matrix(c(1,1,1,1,1,1,1,1,2,2), 5, 2, byrow = TRUE))
par(oma=c(5,7,1,1))
cx <- rev(colorpanel(25,"yellow","black","blue"))
leg <- seq(min(r.cor,na.rm=T),max(r.cor,na.rm=T),length=10)
image(r.cor,main="Correlation plot Normal/Tumor data",axes=F,col=cx)
axis(1, at=seq(0,1,length=ncol(r.cor)), labels=dimnames(r.cor)[[2]], 
    cex.axis=0.9,las=2)
axis(2,at=seq(0,1,length=ncol(r.cor)), labels=dimnames(r.cor)[[2]],
     cex.axis=0.9,las=2)
image(as.matrix(leg),col=cx,axes=T)     

오류 plot.new(): 그림 여백이 너무 큼

tmp <- round(leg,2)
axis(1,at=seq(0,1,length=length(leg)), labels=tmp,cex.axis=1)

문제는 layout()호출로 생성 된 작은 그림 영역 2 가 플롯은 말할 것도없고 기본 여백 만 포함 할만큼 충분히 크지 않다는 것입니다.

문제를 일으키는 라인이 나오기 전에

par(mar = rep(2, 4))

그런 다음 두 번째 이미지를 플로팅합니다.

image(as.matrix(leg),col=cx,axes=T)

이 문제를 해결하려면 par()내가 보여주는 통화 에서 여백의 크기 를 조정해야합니다. 플로팅 할 실제 장치의 크기를 늘려야 할 수도 있습니다.

마지막 팁은 par()기본값을 변경하기 전에 저장 하므로 기존 par()호출을 다음 과 같이 변경하십시오 .

op <- par(oma=c(5,7,1,1))

그런 다음 플로팅이 끝나면

par(op)

이 오류는 단순히 "Plots"창이 너무 작기 때문에 Rstudio에서 발생할 수 있습니다. "파일, 플롯, 패키지, 도움말, 뷰어"를 확대 해보고 도움이되는지 확인하십시오!


RStudio에서이 메시지가 표시되는 경우 Plots 탭에서 'broomstick'그림 "Clear All Plots"를 클릭 하고 plot ()을 다시 시도하면 작동 할 수 있습니다.

여기에 이미지 설명 입력


이것은 때때로 RStudio에서 발생합니다. 이를 해결하기 위해 외부 창에 플롯을 시도 할 수 있습니다 (Windows 전용).

windows() ## create window to plot your file
## ... your plotting code here ...
dev.off() 

R Studio에서이 오류가 발생했으며 가장자리를 오른쪽에서 왼쪽으로 클릭하고 드래그하여 사이드 바를 더 크게 만들어 간단히 수정했습니다.


개체가 목록인지 벡터인지 확인합니다. 이렇게하려면을 입력하십시오 is.list(yourobject). 이것이 사실이면 이름을 바꾸십시오 x<-unlist(yourobject). 이것은 당신이 플로팅 할 수있는 벡터로 만들 것입니다.


여기에 이미지 설명 입력

RStudio를 사용하는 경우이 영역을 확대하면됩니다.


고차원 데이터를 플롯하려고 할 때이 오류가 발생했습니다. 그것이 당신과 함께 진행되고 있다면 다차원 스케일링을 시도 하십시오 : http://www.statmethods.net/advstats/mds.html


몇 주 동안이 오류로 고생했습니다 (RStudio 사용). 플롯 창을 더 크고 더 작게 이동하려고했지만 일관되게 도움이되지 않았습니다. 응용 프로그램을 더 큰 모니터로 옮겼을 때 (드래그) 문제가 사라졌습니다! 깜짝 놀랐습니다 ... 너무 많은 시간을 낭비했습니다 ... 내 코드가 정확하다는 것을 알았습니다 ...


RStudio Plots canvas is limiting the plot width and heights. However if you make your plot from Rmarkdown code chunk, it works without canvas field limitation because plotting area set according to the paper size.

For instance:

    ```{r}
#inside of code chunk in Rmarkdown
        grid <- par(mfrow=c(4, 5))
        plot(faithful, main="Faithful eruptions")
        plot(large.islands, main="Islands", ylab="Area")
        ...
        par(grid)
    ```

I found this error today. Initially, I was trying to output it to a .jpeg file with low width and height.

jpeg("method1_test.jpg", width=900, height=900, res=40)

Later I increased the width and height to:

jpeg("method1_test.jpg", width=1900, height=1900, res=40)

The error was not there. :)

You can also play with the resolution, if the resolution is high, you need more width and height.


I found the same error today. I have tried the "Clear all Plots" button, but it was giving me the same error. Then this trick worked for me, Try to increase the plot area by dragging. It will help you for sure.


모든 플롯 지우기를 사용한 다음 다시 플롯 명령을 내 렸으며 도움이되었습니다.

참고 URL : https://stackoverflow.com/questions/12766166/error-in-plot-new-figure-margins-too-large-in-r

반응형