title: ggplot: How to make the x/time-axis of a time-series plot only the time-component, not the date?
body: <p>Consider the following example</p>
  
  <pre><code>library(lubridate)
  library(tidyverse)
  library(scales)
  library(ggplot2)
  
  dataframe &lt;- data_frame(time = c(ymd_hms('2008-01-04 00:00:00'),
                                   ymd_hms('2008-01-04 00:01:00'),
                                   ymd_hms('2008-01-04 00:02:00'),
                                   ymd_hms('2008-01-04 00:03:00'),
                                   ymd_hms('2008-01-05 00:00:00'),
                                   ymd_hms('2008-01-06 00:01:00'),
                                   ymd_hms('2008-01-07 00:02:00'),
                                   ymd_hms('2008-01-08 00:03:00')),
                          value = c(1,2,3,4,5,6,7,8))
  
  # A tibble: 8 × 2
                   time value
                 &lt;dttm&gt; &lt;dbl&gt;
  1 2008-01-03 19:00:00     1
  2 2008-01-03 19:01:00     2
  3 2008-01-03 19:02:00     3
  4 2008-01-03 19:03:00     4
  5 2008-01-04 19:00:00     5
  6 2008-01-05 19:01:00     6
  7 2008-01-06 19:02:00     7
  8 2008-01-07 19:03:00     8
  </code></pre>
  
  <p>What I need to do is simple: I need to compute the average of <code>value</code> <strong>at the same hour-minute-second</strong> over all days in my sample, and plot it. </p>
  
  <p>I have done the following:</p>
  
  <pre><code>dataframe &lt;- dataframe %&gt;% 
    mutate(hour = strftime(time, format="%H:%M:%S")) %&gt;% 
    group_by(hour) %&gt;% 
    summarize(mean = mean(value)) %&gt;% 
    ungroup()
  
  &gt; dataframe
  # A tibble: 4 × 2
        hour  mean
       &lt;chr&gt; &lt;dbl&gt;
  1 19:00:00     3
  2 19:01:00     4
  3 19:02:00     5
  4 19:03:00     6
  
  ggplot(dataframe, aes(x = hour, y = mean, group = 1)) + 
    geom_line(size = 2) 
  </code></pre>
  
  <p>I have two problems with this approach</p>
  
  <ol>
  <li>Obviously, R does not understand that the x-axis has a time meaning. This is just a character vector.</li>
  <li>Therefore, I cannot control efficiently the x-axis using <code>scale_x_discrete(breaks= scales::pretty_breaks(n = 10)</code>. This is a big problem because my data is at the minutely frequency over a full day. Way too many labels on the x axis.</li>
  </ol>
  
  <p>Can someone do better here? Is it possible to keep some sort of time variable on x-axis, even though there is no specific date associated with these hours?</p>
  
  <p>Thanks!</p>