[英]Aesthetics must either be length one or the same length
I am trying to plot values and errorbars, a seemingly simple task. 我正在尝试绘制值和错误栏,这看似简单。 As the script is fairly long, I am trying to limit the code in give here to the necessary amount.
由于脚本相当长,因此我试图将此处的代码限制为必要的数量。
I can plot the graph without error bars. 我可以绘制没有误差线的图形。 However, when trying to add the errorbars I get the message
但是,当尝试添加错误栏时,我收到消息
Error: Aesthetics must either be length one, or the same length as the dataProblems:Tempdata
This is the code I am using. 这是我正在使用的代码。 All vectors in the Tempdata data frame are of length 390.
Tempdata数据帧中的所有向量的长度均为390。
Tempdata <- data.frame (TempDiff, Measurement.points, Room.ext.resc, MelatoninData, Proximal.vs.Distal.SD.ext, ymax, ymin)
p <- ggplot(data=Tempdata,
aes(x = Measurement.points,
y = Tempdata, colour = "Temperature Differences"))
p + geom_line(aes(x=Measurement.points, y = Tempdata$TempDiff, colour = "Gradient Proximal vs. Distal"))+
geom_errorbar(aes(ymax=Tempdata$ymax, ymin=Tempdata$ymin))
The problem is that you have the colour-variables between quotation marks. 问题是引号之间有颜色变量。 You should put the variable name at that spot.
您应该将变量名放在该位置。 So, replacing
"Temperature Differences"
with TempDiff
and "Gradient Proximal vs. Distal"
with Proximal.vs.Distal.SD.ext
will probably solve your problem. 因此,更换
"Temperature Differences"
与TempDiff
和"Gradient Proximal vs. Distal"
与Proximal.vs.Distal.SD.ext
可能会解决您的问题。
Furthermore: you can can't call for two different colour
-variables. 此外:您不能要求两个不同的
colour
变量。
The improved ggplot code should probably be something like this: 改进的ggplot代码可能应该是这样的:
ggplot(data=Tempdata, aes(x=Measurement.points, y=TempDiff, colour=Proximal.vs.Distal.SD.ext)) +
geom_line() +
geom_errorbar(aes(ymax=ymax, ymin=ymin))
I also fixed some more problems with your original code: 我还修复了原始代码的其他一些问题:
$
issue reported by Roland $
问题 aes
aes
通话相互冲突的事实 aes
aes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.