2011-12-23 121 views
0

我試圖在基本圖形中重現Fry圖形(請參見下文),並最終在該圖形上繪製數值值點。 enter image description here繪製非均勻間隔軸

此圖形在y軸上包含不均勻的間隔。我從這裏的其他帖子收集我需要輸入labels作爲字符,但我似乎無法得到正確的。我有兩個問題,我需要幫助:

  1. 如何以正確y軸上繪製標籤(Y)
  2. 後來,當我需要添加點(見代碼結尾)我怎麼會能否將 繪製到不是數字的y軸上的數字點?

CODE:

Y <- c('2.0', '2.5', '3.0', '3.3', '3.5', '3.6', '3.7', '3.8', '4.0', '4.2', '4.3', 
      '4.5', '4.8', '5.0', '5.2', '5.6', '5.9', '6.3', '6.7', '7.1', '7.7', '8.3', 
      '9.1', '10.0', '11.1', '12.5', '14.3', '16.7', '20.0', '20+') 

X11(14, 10) 
plot(1, 1, xlim=c(108,172), axes=FALSE, type='n', 
    xlab="Average number of syllables per 100 words", 
    ylab="Average number of sentences per 100 words", 
    main="Fry Graph for Estimating Reading Ages (grade level)", 
    xaxs = 'i', yaxs = 'i') 

axis(1, at = 108:172, labels = TRUE) 
axis(2, at = 2:25, labels=Y) 
grid(nx=64, ny=46, lty="solid", col="gold") 
grid(nx=32, ny=23, lty="solid", col="gray65") 
box() 

y <-c(5, 5.9) 
x <-c(128, 136) 
points(x, y) 
+0

我已經決定這太令人費解。我會用數字來重現它。 – 2011-12-23 20:23:41

回答

1

您需要解決這種差異:通過添加ylim在劇情呼叫=範圍(在範圍)參數

> length(Y) 
[1] 30 
> length(2:25) 
[1] 24 

然後,應該能夠在任何你想要的地方「繪製」。此時ylim正在由c(1,1)的數據範圍設置。

(和Las = 2轉動標籤:)

plot(1, 1, xlim=c(108,172), axes=FALSE, type='n', ylim=c(1,30), 
    xlab="Average number of syllables per 100 words", 
    ylab="Average number of sentences per 100 words", 
    main="Fry Graph for Estimating Reading Ages (grade level)", 
    xaxs = 'i', yaxs = 'i') 

axis(1, at = 108:172, labels = TRUE) 
axis(2, at = 1:30, labels=Y, las=2) 
grid(nx=64, ny=46, lty="solid", col="gold") 
grid(nx=32, ny=23, lty="solid", col="gray65") 
box() 

enter image description here