-2

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. 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,

plot 1

plot 2

My POSIXct values are in the format: "2018-03-13 10:18:14" for every visit. Am I plotting these date times incorrectly?

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Would just a histogram work? Or use `cut()` and make a `barplot()`? – MrFlick Aug 05 '20 at 21:37
  • `options(scipen = 999)` – Ronak Shah Aug 06 '20 at 04:18

1 Answers1

0

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. It may be that the format you are passing to hist is setting the y-axis to scientific notation. Regardless, neither 1.0e-08 nor 0.00000001 are very readable. Since the probability densities are so small, your histograms may be more intelligible if you set freq = TRUE to show the counts.

Ben Norris
  • 5,639
  • 2
  • 6
  • 15