[R] Axis whitout all the row, that contains time
Rui Barradas
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Fri Feb 12 19:24:35 CET 2021
Hello,
In order to select every 20 s, set the date_breaks = "20 secs", not the
breaks.
The axis labels are also formatted, with date_labels, standard datetime
format strings are used for this. And rotated, not part of the question.
# Create some data
set.seed(2021)
time <- seq(as.POSIXct("2021-02-11"), as.POSIXct("2021-02-11 00:29:59"),
by = "1 secs")
y <- cumsum(rnorm(length(time)))
df1 <- data.frame(time, y)
# Plot the data
library(ggplot2)
ggplot(df1, aes(time, y)) +
geom_line() +
scale_x_datetime(date_breaks = "20 secs", date_labels = "%M:%S") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1,
size = 5))
Hope this helps,
Rui Barradas
Às 15:05 de 12/02/21, Informatique escreveu:
> Hello,
>
> i'm using Rstudio from a few day, and i have some information in a CVS file, take every five second, format of the time is HH:MM:SS.
> I use the hour on the X axis, but i don't want having all the time print. For example only every 10 values.
>
> I think it will be possible with scale_x_datetime(breaks = date_breaks(XXX)
>
> but i don't understand how select every 20 s.
>
> Thank's for your help
>
> François-marie BILLARD
>
More information about the R-help
mailing list