title: How to plot stacked & segmented bar chart over time?
body: <p>I have data for weather conditions, over the duration of a quarter, that I need to analyse. An example of my data is below:</p>
  
  <pre><code># Example dataset
  Quarter &lt;- c("Q1", "Q2", "Q2", "Q2", "Q3", "Q4")
  Weather &lt;- c("cloudy", "cloudy", "sunny", "cloudy", "sunny", "cloudy")
  Duration &lt;- c(16, 10, 2, 5, 15, 14)
  WeatherCondData &lt;- data.frame(Quarter, Weather, Duration, stringsAsFactors = F)
  </code></pre>
  
  <p>I manually set the factor order and then plot in <code>ggplot2</code> using the following code:</p>
  
  <pre><code># Make quarter a factor
  WeatherCondData$Quarter &lt;- as.factor(WeatherCondData$Quarter)
  # Plot
  ggplot(WeatherCondData, aes(x = Quarter, y = Duration, fill = Weather)) +
    geom_bar(stat = "identity", position = "stack") +
    coord_flip() +
    scale_x_discrete(limits = rev(levels(WeatherCondData$Quarter))) +
    theme_classic() +
    theme(legend.position = "bottom")
  </code></pre>
  
  <p>However, I wish for the plot to show how long the weather conditions lasted for according to the time length of the quarter. For example, in Q2, I wish for the first part of the <code>geom_bar</code> to be red for 10 minutes, signalling cloudy conditions, then change blue for 2 minutes at the 12 minute mark (indicating it is sunny) and then back to blue or cloudy for the final 5 minutes. </p>
  
  <p>In essence, I don't wish to show total durations for each condition over the quarter, but highlight when conditions change.
  Is this possible using ggplot2?</p>