我试图在基本图形中重现Fry Graph(见下文),并最终绘制该图上的数值点。
此图表包含y轴上的不均匀间隔。我从这里的其他帖子中收集到,我需要以字符形式输入labels
,但我似乎无法理解它。我有两个需要帮助的问题:
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 :(得分:1)
您需要解决这种差异:
> length(Y)
[1] 30
> length(2:25)
[1] 24
然后通过在绘图调用中添加ylim = range(at-range)参数,您应该可以根据需要绘制“at”。此时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()