我试图将两个名为Canopy_index(响应变量)和Lighting(解释变量)的列(下面的数据框)绘制到散点图上。绘制观测值时,数据点主要错误地绘制在图表的左侧(下图),这可能归因于x轴上的错误设置或基本图形设置需要更改。在数据框内,照明列中的值通常介于0到<20之间。
目标
问题在于我想操纵和改变x轴值的范围(在0到20.0之间),以便在第1侧或x轴的整个宽度上以0.5的增量展开观察值。 (即0,0.5,1.0,1.5 ...... 20)。
我尝试了不同的方法,但输出结果总是一样的。此外,情节中有一个虚假的异常值;但是,我无法在数据中检测到这个数据点。
如果有人可以提供帮助,那么非常感谢。
代码
plot(Canopy_index~Lighting,
xaxt="n", pch=16,
col="blue",
xlab="Artificial Lighting",
ylab="Canopy Index",
data=Distance_light)
axis(1, at=seq(0, 20, by=0.5), las=2)
剧情
数据
structure(list(Canopy_index = c(75, 85, 75, 35, 85, 95, 85, 65,
75, 95, 75, 95, 85, 75, 85, 95, 75, 85, 85, 85, 75, 75, 85, 85,
65, 85, 75, 85, 95, 95, 85, 55, 75, 95, 75, 95, 95, 65, 65, 55,
95, 85, 85, 45, 85, 85, 35, 95, 85, 85, 35, 85, 45, 85, 85, 85,
95, 85, 85, 75, 85, 35, 85, 85, 65, 65, 85, 45, 55, 95, 75, 95,
45, 75, 75, 95, 95, 85, 75, 95, 75, 65, 85, 75, 75, 55, 75, 85,
85, 85, 15, 75, 85, 85, 85, 95, 85, 85, 85, 75, 85, 85, 95, 65,
75, 95, 55, 75, 85, 85, 85, 95, 55, 85, 75, 75, 85, 85, 85, 85,
55, 75, 55, 75, 85, 75, 85, 85, 75, 85, 75, 95, 25, 95, 95, 25,
75, 75, 85, 35, 55, 85, 65, 85, 75, 85, 85, 85, 75, 65, 85, 85,
95, 65, 55, 95, 95, 85, 95, 85, 65, 55, 65, 55, 95, 75, 85, 85,
35, 75, 75, 85, 65, 85, 65, 65, 95, 85, 95, 75, 75, 55, 95, 65,
85, 65, 15, 35, 55, 95, 15, 15, 75, 65, 85, 5, 5, 35, 35, 85,
65, 45, 35, 65, 65, 75, 65, 15, 75, 65, 45, 25, 65, 85, 45, 85,
75, 15, 65, 45, 55, 45, 15, 45, 75, 65, 75, 65, 35, 95, 65, 35,
35, 65, 45, 75, 35, 75, 85, 35, 55, 65, 85, 65, 65, 85, 55, 15,
75, 65, 45, 45, 85, 55, 15, 85, 15, 95, 75, 5, 55, 15, 35, 45,
85, 65, 65, 65, 65, 25, 85, 35, 55, 65, 75, 5, 45, 65, 15, 75,
55, 65, 55, 35, 75, 65, 65, 85, 35, 65, 55, 75, 15, 55, 65, 75,
55, 85, 35, 55, 55, 25, 75, 15, 55, 75, 75, 65, 55, 45, 75, 25,
45, 95, 55, 75, 45, 25, 35, 55, 15, 15, 75, 35, 55, 55, 65, 45,
65, 25, 55, 45, 65, 65, 25, 25, 65, 45, 95, 55, 25, 55, 85, 45,
85, 15, 75, 65, 35, 75, 15, 55, 85, 35, 55, 45, 85, 45, 65, 55,
75, 65, 85), Lighting = c(2.5, 20, 20, 20, 20, 20, 20, 20, 20,
20, 5, 20, 7.5, 20, 20, 20, 20, 5.5, 15, 20, 5, 20, 20, 20, 20,
20, 20, 7.5, 20, 20, 7.5, 20, 2.5, 20, 15, 20, 20, 20, 20, 20,
20, 20, 20, 15, 20, 2.5, 7.5, 15, 20, 20, 20, 20, 7.5, 20, 2.5,
20, 20, 20, 20, 20, 20, 20, 15, 20, 20, 2.5, 20, 20, 20, 15,
15, 20, 20, 20, 20, 15, 15, 20, 2.5, 20, 2.5, 20, 20, 20, 20,
20, 20, 15, 20, 20, 5, 5, 20, 20, 20, 20, 20, 7.5, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 15, 7.5,
20, 20, 20, 20, 20, 20, 2.5, 20, 20, 2.5, 20, 20, 15, 20, 20,
20, 7.5, 15, 20, 7.5, 20, 20, 20, 20, 20, 15, 20, 20, 20, 20,
20, 20, 20, 2.5, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
15, 7.5, 2.5, 15, 20, 20, 15, 20, 7.5, 8, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 15, 20, 20, 15, 20, 15, 20, 20, 7.5, 20, 20, 7.5, 20, 20,
20, 20, 20, 20, 15, 20, 7.5, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 15, 15, 75, 20, 20, 20, 20, 20, 20, 2.5,
20, 20, 2.5, 15, 20, 20, 7.5, 15, 20, 20, 7.5, 20, 20, 20, 20,
20, 15, 20, 20, 15, 20, 15, 7.5, 2.5, 20, 7.5, 20, 20, 7.5, 20,
20, 20, 15, 20, 20, 20, 7.5, 20, 7.5, 20, 20, 20, 7.5, 8, 20,
20, 20, 20, 20, 20, 20, 20, 7.5, 20, 20, 20, 20, 20, 7.5, 20,
7.5, 20, 20, 20, 20, 20, 15, 20, 20, 2.5, 20, 20, 20, 20, 20,
20, 20, 2.5, 7.5, 20, 7.5, 20, 2.5, 20, 20, 20, 15, 20, 20, 20,
20, 20, 20, 20, 7.5, 20, 20, 20, 20, 20, 20, 20, 20, 20, 2.5,
7.5, 2.5, 15, 20, 20, 15, 20, 20, 20, 20, 20, 15, 20, 20, 20,
20, 20, 20, 20, 20, 15)), .Names = c("Canopy_index", "Lighting"
), row.names = c(NA, -363L), class = "data.frame")
答案 0 :(得分:3)
第230行有一个异常值,这就是你获得该图表的原因。
> Distance_light[Distance_light$Lighting == 75, ]
Canopy_index Lighting
230 95 75
如果删除它,它可以正常工作:
plot(Distance_light$Lighting[-230],
Distance_light$Canopy_index[-230],
pch=16,
col="blue",
xlab="Artificial Lighting",
ylab="Canopy Index",
xaxt='n')
axis(1, at=seq(0, 20, by=0.5), las=2)