简体   繁体   English

在 R 中绘制 POSIXct 值

[英]plotting POSIXct values in R

Im trying to plot datetimes of customer visits using a histogram but for some reason my plots are producing scientific notation for the y axis.我正在尝试使用直方图 plot 客户访问的日期时间,但由于某种原因,我的绘图正在为 y 轴生成科学记数法。 My code is as follows:我的代码如下:

hist(tsData, breaks = "months", plot = TRUE, freq = FALSE,
     start.on.monday = TRUE, format)

hist(tsData, breaks = "hours", plot = TRUE, freq = FALSE,
     start.on.monday = TRUE, format)

Which produce the following plots respectively,分别产生以下图,

情节 1

情节2

My POSIXct values are in the format: "2018-03-13 10:18:14" for every visit.我的 POSIXct 值的格式为:每次访问的“2018-03-13 10:18:14”。 Am I plotting these date times incorrectly?我是否错误地绘制了这些日期时间?

Without seeing your data, I cannot tell for certain, but your horizontal axes seem to suggest you are plotting the date-times correctly.如果没有看到您的数据,我无法确定,但您的水平轴似乎表明您正在正确绘制日期时间。

As for your vertical axis, it is showing scientific notation because the density values are very small.至于你的垂直轴,它显示科学计数法,因为密度值非常小。 In your first plot, 1.0e-08 is the same as 0.00000001 .在您的第一个 plot 中, 1.0e-080.00000001相同。 It may be that the format you are passing to hist is setting the y-axis to scientific notation.您传递给histformat可能是将 y 轴设置为科学记数法。 Regardless, neither 1.0e-08 nor 0.00000001 are very readable.无论如何, 1.0e-080.00000001都不是非常可读的。 Since the probability densities are so small, your histograms may be more intelligible if you set freq = TRUE to show the counts.由于概率密度非常小,如果您设置freq = TRUE来显示计数,您的直方图可能更容易理解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM