[英]How to plot Time Interval only on x axis without date?
I am using R-3.2.4. 我正在使用R-3.2.4。 I have been trying to plot the data with only time on x axis and some value on y axis but everytime it shows some date on along with time on x axis, however i need only time interval on x axis. 我一直在尝试只在x轴上显示时间,在y轴上显示一些值,但是每次它在x轴上显示一些日期以及时间时,但是我只需要在x轴上显示时间间隔。
Here is the code that i am using: 这是我正在使用的代码:
data_plot<- read.csv("C:/.../Data_pract.csv",header=TRUE,stringsAsFactors=F)
data_plot$Time<-as.POSIXct(strptime(data_plot$Time, format="%H:%M"))
mydata<-ggplot(data_plot,aes(x=Time,y=January))+geom_line()
mydata
Here is the sample data that i am using: 这是我正在使用的示例数据:
Time January
0:00 20
0:15 30
0:30 45
0:45 40
1:00 28
1:15 15
I have attached image of graph that i am looking for. 我已附上我正在寻找的图形图像。
Thanks in advance. 提前致谢。 enter image description here 在此处输入图片说明
You can change the scale in ggplot to datetime by using the function scale_x_datetime 您可以使用scale_x_datetime函数将ggplot中的小数位数更改为datetime
mydata<-ggplot(data_plot,aes(x=Time,y=January)) + geom_line() +
scale_x_datetime(date_breaks = "1 hour",
date_labels = "%I:%M %p")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.