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
Informatique <informatique at billard-francois-marie.eu>
With a dat.frame "mydata" create a new variable mydata$num
mydata$num <- 1:nrow(mydata)
new_data <- subset(mydata, num == 10)
plot using new_data
On Fri, 12 Feb 2021 at 10:35, Informatique <
informatique at billard-francois-marie.eu> wrote:
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
--
Informatique <informatique at billard-francois-marie.eu>
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
Hello,
the time are in the first table like that : 10:24:00
and i use this for
listeMesuresPropres$Heure. <- hms(listeMesuresPropres$Heure.
after time ar like that : 10H 24M 0S
and when i use with ggplot
scale_x_time(breaks = "20 secs",labels = "%H:%M:%S")
it have the graphics but noting write on the X axis.
I think it a problem with the format of the time, because if i try a ggplot without scale_x_time i don't have anything on the graphic.
Thank's
Fran?ois-Marie BILLARD
On Fri, 12 Feb 2021 18:24:35 +0000
Rui Barradas <ruipbarradas at sapo.pt> wrote:
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
Informatique <informatique at billard-francois-marie.eu>
Hello,
It's not scale_x_time with arguments breaks and labels.
It's scale_x_datetime with arguments
date_breaks and date_labels.
If you also want the hour displayed in the x axis labels, change the
format string in my previous post to
scale_x_datetime(date_breaks = "20 secs", date_labels = "H:%M:%S")
Can you post as data sample the output of dput?
dput(head(listeMesuresPropres, 20)) # or 30
Hope this helps,
Rui Barradas
?s 07:35 de 14/02/21, Informatique escreveu:
Hello,
the time are in the first table like that : 10:24:00
and i use this for
listeMesuresPropres$Heure. <- hms(listeMesuresPropres$Heure.
after time ar like that : 10H 24M 0S
and when i use with ggplot
scale_x_time(breaks = "20 secs",labels = "%H:%M:%S")
it have the graphics but noting write on the X axis.
I think it a problem with the format of the time, because if i try a ggplot without scale_x_time i don't have anything on the graphic.
Thank's
Fran?ois-Marie BILLARD
On Fri, 12 Feb 2021 18:24:35 +0000
Rui Barradas <ruipbarradas at sapo.pt> wrote:
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
Hello,
It's not scale_x_time with arguments breaks and labels.
It's scale_x_datetime with arguments
date_breaks and date_labels.
If you also want the hour displayed in the x axis labels, change the
format string in my previous post to
scale_x_datetime(date_breaks = "20 secs", date_labels = "H:%M:%S")
Can you post as data sample the output of dput?
dput(head(listeMesuresPropres, 20)) # or 30
Hope this helps,
Rui Barradas
?s 07:35 de 14/02/21, Informatique escreveu:
Hello,
the time are in the first table like that : 10:24:00
and i use this for
listeMesuresPropres$Heure. <- hms(listeMesuresPropres$Heure.
after time ar like that : 10H 24M 0S
and when i use with ggplot
scale_x_time(breaks = "20 secs",labels = "%H:%M:%S")
it have the graphics but noting write on the X axis.
I think it a problem with the format of the time, because if i try a ggplot without scale_x_time i don't have anything on the graphic.
Thank's
Fran?ois-Marie BILLARD
On Fri, 12 Feb 2021 18:24:35 +0000
Rui Barradas <ruipbarradas at sapo.pt> wrote:
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
Informatique <informatique at billard-francois-marie.eu>
Hello,
Merci pour les donn?s, c'est beaucoup mieux comme ?a.
Create a column of class "POSIXct"
listeMesuresPropres$DateHeure <- with(listeMesuresPropres,
as.POSIXct(paste(Date., Heure.)))
and then plot with this new column, DateHeure as x axis variable.
Can you post the entire ggplot code, not just the scale_x_datetime
instruction but the rest of the plotting code?
Hope this helps,
Rui Barradas
?s 13:25 de 14/02/21, Informatique escreveu:
Hello,
It's not scale_x_time with arguments breaks and labels.
It's scale_x_datetime with arguments
date_breaks and date_labels.
If you also want the hour displayed in the x axis labels, change the
format string in my previous post to
scale_x_datetime(date_breaks = "20 secs", date_labels = "H:%M:%S")
Can you post as data sample the output of dput?
dput(head(listeMesuresPropres, 20)) # or 30
Hope this helps,
Rui Barradas
?s 07:35 de 14/02/21, Informatique escreveu:
Hello,
the time are in the first table like that : 10:24:00
and i use this for
listeMesuresPropres$Heure. <- hms(listeMesuresPropres$Heure.
after time ar like that : 10H 24M 0S
and when i use with ggplot
scale_x_time(breaks = "20 secs",labels = "%H:%M:%S")
it have the graphics but noting write on the X axis.
I think it a problem with the format of the time, because if i try a ggplot without scale_x_time i don't have anything on the graphic.
Thank's
Fran?ois-Marie BILLARD
On Fri, 12 Feb 2021 18:24:35 +0000
Rui Barradas <ruipbarradas at sapo.pt> wrote:
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
Hello,
with the new column all works fine, i can now select the break and format for the x axis.
Thank's
Fran?ois-Marie
On Sun, 14 Feb 2021 14:24:22 +0000
Rui Barradas <ruipbarradas at sapo.pt> wrote:
Hello,
Merci pour les donn?s, c'est beaucoup mieux comme ?a.
Create a column of class "POSIXct"
listeMesuresPropres$DateHeure <- with(listeMesuresPropres,
as.POSIXct(paste(Date., Heure.)))
and then plot with this new column, DateHeure as x axis variable.
Can you post the entire ggplot code, not just the scale_x_datetime
instruction but the rest of the plotting code?
Hope this helps,
Rui Barradas
?s 13:25 de 14/02/21, Informatique escreveu:
Hello,
It's not scale_x_time with arguments breaks and labels.
It's scale_x_datetime with arguments
date_breaks and date_labels.
If you also want the hour displayed in the x axis labels, change the
format string in my previous post to
scale_x_datetime(date_breaks = "20 secs", date_labels = "H:%M:%S")
Can you post as data sample the output of dput?
dput(head(listeMesuresPropres, 20)) # or 30
Hope this helps,
Rui Barradas
?s 07:35 de 14/02/21, Informatique escreveu:
Hello,
the time are in the first table like that : 10:24:00
and i use this for
listeMesuresPropres$Heure. <- hms(listeMesuresPropres$Heure.
after time ar like that : 10H 24M 0S
and when i use with ggplot
scale_x_time(breaks = "20 secs",labels = "%H:%M:%S")
it have the graphics but noting write on the X axis.
I think it a problem with the format of the time, because if i try a ggplot without scale_x_time i don't have anything on the graphic.
Thank's
Fran?ois-Marie BILLARD
On Fri, 12 Feb 2021 18:24:35 +0000
Rui Barradas <ruipbarradas at sapo.pt> wrote:
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
Informatique <informatique at billard-francois-marie.eu>