Hello,

Maybe you could get some inspiration in the following code.


op <- par(mar = c(4, 0, 0, 0) + par("mar"))

plot(xdata, ydata, type = "o", xaxt = "n")
axis.POSIXct(1, xdata, at = xdata, labels = xdata, las = 2)

par(op)


The important part is the call axis.POSIXct, argument las = 2 and the call to par is to make sure that the labels are visible.


Hope this helps,

Rui Barradas


Às 15:16 de 28/10/2018, snowball0916 escreveu:
Hi, guys
How do you guys deal with the date and time data on x axis?
I have some trouble with it. Could you help with this?

=============
Sample Data
=============
The sample data look like this:

20181028_10:00:00 600
20181028_10:00:01 500
20181028_10:00:02 450
20181028_10:00:03 660
......

=============
My Code
=============

library(lubridate)
mydata <- read.table("e:/R_study/graph_test2.txt")
xdata <- ymd_hms(mydata$V1)
ydata <- mydata$V2
plot(xdata, ydata, type="o")


=============
Questions:
=============

1. Why my x axis does not show me the correct date time like ""2018-10-28 10:00:00 
UTC" ?
2. If my data is very huge(like data in every second and the data has the whole 
day , even the whole month), how can I display the x axis in a neat and clean 
way?

Thanks very much.


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to