我想用ggplot2建立一个情节.因此,我使用geom_line来显示线条和geom_smooth以显示特定索引的Min-Max-Range.使用两个数据帧,第一行包括日期(例如:2013-02-04),下一个是测量值(例如2.532283).
首先,我生成一个包含所有样式的空ggplot:
yrange_EVI2 =是索引的范围(最小 - 最大) xrange =是x轴的日期范围(最早 - 最新日期)
EVI2_veg <- ggplot() + geom_blank() +
ylim(yrange_EVI2) + xlim(xrange) +
ggtitle("EVI2 for reference-data in Azraq (Jordan)") + ylab("EVI2") + xlab("month") +
theme_bw(base_size = 12, base_family = "Times New Roman")
Run Code Online (Sandbox Code Playgroud)
第二步是绘制范围(最小 - 最大范围)和具有特定值的平均值的线:
EVI2_veg <- EVI2_veg +
geom_smooth(aes(x=Date, y=Vegetable_mean, ymin=Vegetable_min, ymax=Vegetable_max), data=Grouped_Croptypes_EVI2, stat="identity") +
geom_line(aes(x=Date, y=Tomato), data=Sample_EVI2_A_SPOT)
Run Code Online (Sandbox Code Playgroud)
在最后一步中,我尝试使用scale_fill_manual和scale_color_manual更改颜色:
EVI2_veg <- EVI2_veg +
scale_fill_manual("Min-Max-Range and Mean \nof specific Croptypes",labels=c("Vegetable","Tomato"),values=c("#008B00","#FFFFFF")) +
scale_color_manual("Min-Max-Range and Mean \nof specific Croptypes",labels=c("Vegetable","Tomato"),values=c("#008B00","#CD4F39"))
Run Code Online (Sandbox Code Playgroud)
我阅读了很多答案和特定包的手册,但我不明白我何时使用不同的颜色=""和fill ="":