2014-09-18 3 views
0

축을 0.5에서 1.5로 나누어야합니다. 내 코드는 다음과 같습니다.R- 축 매트 플롯 기능 해제

matplot(wxyz$days_until_last_pay, wxyz[,c(2,3,4,5)], type=c("b"), pch=1, col=1:4, 
     main="x![enter image description here][1]", cex.main=0.8) 
legend("bottomright", inset=c(0,-0.57), fill=NULL, 
     legend = c("mean","median","max", "min"), col=1:4, pch=1, cex=0.8) 
library("plotrix") 
axis.break(axis=2,1,,2,style="zigzag", brw=0.03) 

그러나 나는 그 안에 한 줄 밖에 없습니다. 이것은 축을 깨지 않고 있습니다. enter image description here

어떻게 해결할 수 있습니까? 감사합니다.

+0

을 ... –

답변

0

axis.break은 기존 plot에 중단을 넣습니다. 따라서 축이 "고장"이 아닌 경우 작동하지 않습니다.

하나의 제안은 두 개의 그림을 서로 겹치게하고 그 사이에 0.5와 1.5 사이의 갭이 있도록 (ylim) 설정하는 것입니다.

## Some data, set.seed(1) 
dat <- matrix(c(rnorm(50, 2, 0.1), 
       rnorm(50, 0.2, 0.05), 
       rnorm(50, 0.3, 0.05)), 
       byrow=FALSE, ncol=3) 

## Split the device into two subplots 
par(mfrow = c(2,1)) 

## Set the bottom margin of the top plot to 0.1 
par(mar=c(0.1,4.1,4.1,2)) 

## Top plot (first column of the matrix) 
plot(dat[,1], add=T, type="l", xaxt="n", ylab="", ylim=c(1.5, 2.5)) 

## Set the top margin of the bottom plot to 0.1 
par(mar=c(5.1,4.1,0.1,2)) 

## Bottom plot 
matplot(dat[,2:3], type="l", col=2:3, ylab="", ylim=c(0, 0.5)) 

이 당신에게 같은 것을 제공합니다 : 휴식 위의 데이터에서 그냥 레이블을 변경하고 휴식의 크기가 무엇이든 뺄 수 enter image description here