2
ggplot2のscale_x_datetimeを使用しているときに、x軸に表示されている時刻から先頭のゼロを取り除くことはできますか?scale_x_datetimeを使用して時間の先頭に0を表示しない
ggplot2のscale_x_datetimeを使用しているときに、x軸に表示されている時刻から先頭のゼロを取り除くことはできますか?scale_x_datetimeを使用して時間の先頭に0を表示しない
我々はscales
パッケージからdate_format
を使用することができます。空白が先行し、単一の数字で
%k
24時間のクロック時間:library(ggplot2) library(scales) # dummy data set.seed(1) df1 <- data.frame( x = as.POSIXct(runif(10, 0, 24 * 60 * 60), origin = "2017/04/20"), y = 1:10 ) # use scales::date_format ggplot(df, aes(x = x, y = y)) + geom_point() + scale_x_datetime(labels = date_format("%l:%M"))
?strptime。
%l
1桁の空白で始まる12時間の時計時刻。