Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何同时使用几何图形线和几何图形点更改图例形状?_R_Ggplot2_Time Series - Fatal编程技术网

R 如何同时使用几何图形线和几何图形点更改图例形状?

R 如何同时使用几何图形线和几何图形点更改图例形状?,r,ggplot2,time-series,R,Ggplot2,Time Series,我的数据: 日期;起初的合适的;酚;噪音类型;类型2;类型3;类型4 2013-04-16;0.77;0.76;NA;NA;1.2.3.四, 2013-04-24;NA;0.73;NA;1.1.2.3.四, 2013-05-10;NA;0.70;0.11;NA;1.2.3.四, 2013-05-18;0.68;0.65;NA;1.1.2.3.四, 我想绘制原始时间序列X拟合时间序列,显示一些检测到的时间序列 拟合时间序列上存在噪声的点。但是我在使用图例时遇到了麻烦,一旦我想为每个表示显示正确的图

我的数据:

日期;起初的合适的;酚;噪音类型;类型2;类型3;类型4

2013-04-16;0.77;0.76;NA;NA;1.2.3.四,

2013-04-24;NA;0.73;NA;1.1.2.3.四,

2013-05-10;NA;0.70;0.11;NA;1.2.3.四,

2013-05-18;0.68;0.65;NA;1.1.2.3.四,

我想绘制原始时间序列X拟合时间序列,显示一些检测到的时间序列 拟合时间序列上存在噪声的点。但是我在使用图例时遇到了麻烦,一旦我想为每个表示显示正确的图例

我正在尝试这个:

ggplot(data=df) + geom_line(data=df, aes(x=Date, y=fitted_data, color= >type2)) +  labs(x = "Dates", y="EVI") + 
geom_point(data=df, aes(x=Date, y=original_data, color = type)) +
geom_point(data=df, aes(x=Date, y=phen, color = type3), size =3) +
geom_point(data=df, aes(x=Date, y=noise, color = type4), size =1.2) +
ylim(0, 1) + theme(axis.text.x=element_text(angle=30, hjust=1, size=12)) >+ theme(axis.text.y=element_text(size=12)) +
theme(legend.text=element_text(size = 15), legend.position="bottom")

但我想为每个表示显示正确的符号

ggplot(data=df) + geom_line(data=df, aes(x=Date, y=fitted_data, color= type2)) +  labs(x = "Dates", y="EVI") + 
  geom_point(data=df, aes(x=Date, y=original_data, color = type)) +
  geom_point(data=df, aes(x=Date, y=phen, color = type3), size =3) +
  geom_point(data=df, aes(x=Date, y=noise, color = type4), size =1.2) +
   ylim(0, 1) + theme(axis.text.x=element_text(angle=30, hjust=1, size=12)) + theme(axis.text.y=element_text(size=12)) +
  theme(legend.text=element_text(size = 10), legend.position="bottom")  +
  theme(legend.title=element_blank()) +  scale_colour_manual(values = c("red", "black", "brown", "blue"),
                       guide = guide_legend(override.aes = list(
                         linetype = c("blank", "solid", "blank", "blank"), shape = c(16, NA, 16, 16)
                         )))