在ggplot中获取错误:一元运算符的参数无效

时间:2018-02-28 07:49:06

标签: r plot ggplot2 label

我正在研究几个月的一些数据值。

我对每种数据类型使用两个geom_lines()函数。我得到的情节和我想要的一切,但当我尝试用“月”标记x轴时,我收到一个错误。

Error in +xlab("Months") : invalid argument to unary operator

我的情节代码是:

library(ggplot2)
library(officer)

data <- "U://30-Power & Water//25 Renewables//WORK//Data//PVPlanner//PVPlanner.csv"

data <- read.table(data,skip = 36, header = T,  sep=";")

months <- c("Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec")
data <- data.frame(months, data[1:12,2:6])
data$months <-factor(data$months,levels = c("Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec"))

plot <- ggplot(data) +geom_path(aes(x= months, y= GHId, col = "GHId", group = 1)) + geom_path( aes(x = months,y = Diffd,colour = "Diffd", group = 1) )+ scale_colour_manual("", breaks =c("GHId","Diffd"), values = c( "red","Blue"))
+xlab("Months")+ylabs("Irradiation")+ggtitle("Global and Diffuse horizontal irradiance")
plot

我的数据如下:

  GHId GHIm Diffd Diffm  T24
1     3.27  101  0.92    29 13.3
2     3.92  110  1.23    34 13.3
3     5.30  164  1.58    49 13.9
4     6.18  185  1.89    57 14.9
5     6.93  215  2.00    62 16.4
6     7.53  226  1.80    54 18.4
7     7.42  230  1.87    58 21.1
8     7.06  219  1.58    49 22.0
9     5.97  179  1.39    42 21.3
10    4.50  140  1.26    39 18.7
11    3.53  106  0.99    30 15.9
12    2.90   90  0.86    27 13.3

情节完全没有问题。我只是在尝试给轴标签时才会出错。我不知道为什么会这样。

我们将不胜感激。

此致

0 个答案:

没有答案
相关问题