2013-03-30 6 views
0
나는 다음과 같은 코드로 graph1.jpg를 얻을 수

,R에 좌표축을 설정하는 방법?

x = seq(-0.25, 1.25, length = 400) 
y1=x 
plot(x, y1,type="l",ann=FALSE) 
text(0.3,0.2,labels="y=x") 
mtext("x", 1, at=1.25, line=1) 
mtext("y", 2, at=1.25, line=1) 

어떻게 그래프 2로 그래프 1을 변경할 수 있습니다, 그들 사이의 두 가지 주요 diffrences이있다, graph1.jpg 및 graph2.jpg 비교하세요?

1.To은 그래프 1의 Y 축의 y (그래프 1을 줄 문자
3.To 좌표 축
2.No 화살표 오른쪽 좌표 원점을 설정 graph2's.How에 그래프 1의 좌표축을 변경. jpg) horizontal

이것은 graph1.jpg입니다. enter image description here

이것은 graph2.jpg입니다. graph2.jpg는 gimp에서 만든 것일 수도 있습니다. enter image description here

답변

0

이 얻을 수 arrows, axis 사용 및 일부 plot 매개 변수를 설정 :

enter image description here

## you call plot without axes, without box, without axes labels 
plot(x, y1,type="l",frame.plot=FALSE, 
    axes=FALSE,xlab='',ylab='') 
## write some text 
text(0.3,0.2,labels="y=x") 
text(max(x),-0.1,"x") 
text(-0.1,max(x),'y') 
## draw axes lines with arrows 
arrows(min(x), 0, max(x), 0) 
arrows(0, min(x), 0, max(x)) 
## add axes ticks 
axis(1,at=c(0,0.5,1),pos=0) 
axis(2,at=c(0,0.5,1),pos=0)