title: Align left border of geom_col column with data anchor
body: <p>I'm trying to plot some timestamped data with ggplot2 and R. Here is a minimal and reproducible example of my current work</p>
  
  <blockquote>
  <pre><code>library(lubridate)
  library(ggplot2)
  
  sample_size &lt;- 100
  
  start_date = as.POSIXct("2020-01-01 00:00")
  end_date = as.POSIXct("2020-01-02 00:00")
  
  timestamps &lt;- as.POSIXct(sample(seq(start_date, end_date, by=60), sample_size))
  amount &lt;- rpois(sample_size, 5)
  
  df &lt;- data.frame(timestamps=timestamps, amount=amount)
  
  df$hour_group &lt;- floor_date(df$timestamps, unit="1 hour")
  ggplot(df, aes(x=hour_group, y=amount)) + geom_col()
  </code></pre>
  </blockquote>
  
  <p><strong>Explanation:</strong> First a sample dataframe with the column <em>timestamp</em> and <em>amount</em> is created. The timestamps are uniformly selected between the <code>start_date</code> and <code>end_date</code>. I'd like to plot the <code>amount</code> variable for each hour of the day. Therefore another column <code>hour_group</code> is created and filled with the hour of each timestamp. </p>
  
  <p>Plotting this data yields the following graph:</p>
  
  <p><a href="https://i.stack.imgur.com/uQuPp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uQuPp.png" alt="enter image description here"></a></p>
  
  <p>The columns look alright, but since the first column for example represents the sum of the <code>amount</code> with timestamps between <code>00:00</code> and <code>01:00</code> I'd like the column to fill exactly this space (not <code>23:30</code> to <code>00:30</code> as in the current plot). Therefore I want to align the left border of each column with the anchor point (in the example <code>00:00</code>) and not center the column at this point. How can this be achieved?</p>
  
  <p><strong>My approach:</strong> One way I can think is to created another column with the shifted anchor points. In the example a 30minute shift is necessary. </p>
  
  <blockquote>
  <pre><code>df$hour_group_shifted &lt;- df$hour_group + 60*30
  </code></pre>
  </blockquote>
  
  <p>The new plot creates the expected result</p>
  
  <p><a href="https://i.stack.imgur.com/zVMAf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zVMAf.png" alt="enter image description here"></a></p>
  
  <p>I'm still wondering if there may be a simpler way to achieve this directly with a ggplot setting without the extra column. </p>