简体   繁体   English

美学必须是一个长度或相同的长度

[英]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: 我还修复了原始代码的其他一些问题:

  • the $ issue reported by Roland 罗兰(Roland)报告的$问题
  • the fact that you have conflicting calls in your aes 您的aes通话相互冲突的事实
  • the fact you are calling your dataframe inside the first aes 您呼叫的第一个内部的数据帧的事实aes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 美学必须是长度为 1 或与数据问题相同的长度 - Aesthetics must either be length one, or the same length as the dataProblems 错误:R中的“美学长度必须相同或相同” - Error: “Aesthetics must either be length one or the same length” in R 美学的长度必须为1或与数据相同(500) - Aesthetics must be either length 1 or the same as the data (500) 美学长度必须为1或与数据相同 - Aesthetics must be either length 1 or the same as the data 美学必须是长度 1 或与数据相同 (1) - Aesthetics must be either length 1 or the same as the data (1) 错误:美学的长度必须为1或与数据相同(4) - Error: Aesthetics must be either length 1 or the same as the data (4) 美学必须是长度1或与数据(1)相同:颜色 - Aesthetics must be either length 1 or the same as the data (1): colour R中的boxplot,美学必须是长度1或与数据相同的长度 - boxplot in R, aesthetics must be either length 1 or the same length as data Multiplot有时不起作用-接收错误:美学长度必须为1,或者与数据长度相同 - Multiplot does not work sometimes - receiving Error: Aesthetics must either be length one, or the same length as the dataProblems ggplot2:Aesthetics中的几个图表必须是长度为1或相同的长度 - Several graphs in ggplot2: Aesthetics must either be length one, or the same length
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM