美学必须是长度一或长度相同 [英] Aesthetics must either be length one or the same length
问题描述
我可以绘制没有错误条形图的图形。但是,当试图添加错误条时,我得到消息
错误:美学必须是长度为1或与dataProblems长度相同: Tempdata
这是我使用的代码。 Tempdata数据帧中的所有矢量长度为390.
Tempdata < - data.frame(TempDiff,Measurement.points, Room.xt.resc,MelatoninData,Proximal.vs.Distal.SD.ext,ymax,ymin)
p < - ggplot(data = Tempdata,
aes(x = Measurement.points,$ b $通过= Tempdata,颜色=温差))
p + geom_line(aes(x = Measurement.points,y = Tempdata $ TempDiff,color =Gradient Proximal vs. Distal))+
geom_errorbar (aes(ymax = Tempdata $ ymax,ymin = Tempdata $ ymin))
TempDiff
和渐变近端与远端替换温差
with Proximal.vs.Distal.SD.ext
可能会解决您的问题。 此外:你不能调用两个不同的 color
- 变量。
改进的ggplot代码可能应该是像这样:
ggplot(data = Tempdata,aes(x = Measurement.points,y = TempDiff,color = Proximal。 )+
geom_line()+
geom_errorbar(aes(ymax = ymax,ymin = ymin))
我还修复了一些与原始代码有关的问题:
$ b $内调用数据框b
$
Roland报告的问题
aes
aes
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 <- 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.
Furthermore: you can can't call for two different colour
-variables.
The improved ggplot code should probably be something like this:
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:
- the
$
issue reported by Roland - the fact that you have conflicting calls in your
aes
- the fact you are calling your dataframe inside the first
aes
这篇关于美学必须是长度一或长度相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!