如何删除现有标签并在ggplot2中向x轴添加时标标签?

时间:2016-04-28 11:27:40

标签: r ggplot2

我的数据如下:

Date        B1  B2  B3  B4  B5  B6  B7  B8  B9 B10 B11 B12 B13  B14
10/03/2015  NA 1.8  NA 2.7 1.1 4.4 2.0 0.2 2.1 0.8 1.4 0.6 1.4  1.8
17/03/2015  NA  NA 2.8 0.7 1.7 3.5 2.0 0.3 2.0 1.2 1.0 0.8 1.7  1.0

(+ 26个以上的日期)

我只是想绘制前三列(B1-B3)所以我这样做了:

library(ggplot2)
library(dplyr)
mydata<-read.csv("toc.csv",header=T)
df <- data.frame(mydata$Date, mydata$B1, mydata$B2, mydata$B3)
ggplot(df, aes(mydata$Date, y=value, colour = "red")) +
geom_point(aes(y = mydata$B1, col = "B1")) + 
geom_point(aes(y = mydata$B2, col = "B2")) +
geom_point(aes(y = mydata$B3, col = "B3")) +
labs(title ="Total organic carbon in the Barlwyd 
        upstream sites B1-B3, 2015.", x = "Date",
y = "Total organic carbon (mg/L).") 

结果给出了一个带有杂乱x轴的图形,每个采样日期都放在x轴上。如何整理x轴,使标签显示为每月间隔?我的数据大致每周一次。

提前致谢! 还在学习绳索! ; - )

0 个答案:

没有答案