title: How to reorder the x axis on a stacked area plot
body: <p>I have the following data frame and want to plot a stacked area plot:</p>
  
  <pre><code>library(ggplot2)
  set.seed(11)
  df &lt;- data.frame(a = rlnorm(30), b = as.factor(1:10), c = rep(LETTERS[1:3], each = 10))
  
  ggplot(df, aes(x = as.numeric(b), y = a, fill = c)) + 
      geom_area(position = 'stack') +
      theme_grey() +
      scale_x_discrete(labels = levels(as.factor(df$b))) +
      theme(axis.text.x = element_text(angle = 90, hjust = 1))
  </code></pre>
  
  <p>The resulting plot on my system looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/VOmZC.png" alt="stacked_area_plot"></p>
  
  <p>Unfortunately, the x-axis doesn't seem to show up. I want to plot the values of <code>df$b</code> rotated so that they don't overlap, and ultimately I would like to sort them in a specific way (haven't gotten that far yet, but I will take any suggestions).</p>
  
  <p>Also, according to <code>?factor()</code> using <code>as.numeric()</code> with a factor is not the best way to do it. When I call <code>ggplot</code> but leave out the <code>as.numeric()</code> for <code>aes(x=...</code> the plot comes up empty.</p>
  
  <p>Is there a better way to do this?</p>