Skip to content
Prev 377149 / 398502 Next

date and time data on x axis

Hi, Jim
Thanks very much, I will need to study your code, though.
Will large volume of data will affect the x axis display?
Thanks again. 
 


 
From: jim holtman
Date: 2018-10-29 05:53
To: snowball0916
CC: R mailing list
Subject: Re: [R] date and time data on x axis
You need to specify what the format of the date will be.  I am using
ggplot for the plot:
 
 
    library(lubridate)
    library(tidyverse)
    mydata <- read.table(text = "time value
    20181028_10:00:00 600
    20181028_10:00:01 500
    20181028_10:00:02 450
    20181028_10:00:03 660", header = TRUE, as.is = TRUE)
 
    mydata <- mutate(mydata,
                     time = ymd_hms(time)
    )
 
    ggplot(mydata, aes(time, value)) +
      geom_point() +
      scale_x_datetime(date_labels = "%m/%d %H:%M:%S"
      ) +
      theme(axis.text.x = element_text(angle = 25, vjust = 1.0, hjust = 1.0))
 
Jim Holtman
Data Munger Guru
 
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
 
Jim Holtman
Data Munger Guru
 
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Sun, Oct 28, 2018 at 11:23 AM snowball0916 <snowball0916 at 163.com> wrote: