title: Change order of factors within ggplot facets
body: <p>I am trying to plot multiple plots using <code>facet_grid()</code>, where I would like to have for each facet, a subset of different factor levels, plotted along the X-axis in manual order. </p>
  
  <p>Basically I want to plot top 5 countries (manually defined) on the each X axis, and I can use an alternative solution with <code>grid.arrange()</code> (see example), but I would like to make it with <code>facet_grid()</code> or <code>facet_wrap()</code> to keep the same aesthetics as with the rest of my plots.</p>
  
  <p>I could find some answers to sort facets by factor level, and I tried playing with the order aesthetic, but without success, so I am wondering if there is a way to do something like this, even though I am aware that faceting in ggplot isn't designed with modifying the axes in mind. I would appreciate some advices on this.</p>
  
  <p>Here is a reproducible example of what I want (manually defined order on X-axes).</p>
  
  <pre><code>library(reshape)
  library(ggplot2)
  library(gridExtra)
  
  # Load data
  mtcars_melt &lt;- melt(mtcars)
  
  # Subset data
  set1 &lt;- subset(mtcars_melt, variable == "mpg" | variable == "wt" | variable == "qsec")
  set2 &lt;- subset(mtcars_melt, variable == "gear" | variable == "cyl" | variable == "mpg")
  set3 &lt;- subset(mtcars_melt, variable == "drat" | variable == "vs" | variable == "mpg")
  
  # Order factors
  set1$variable &lt;- factor(set1$variable, levels = c("mpg", "wt", "qsec"))
  set2$variable &lt;- factor(set2$variable, levels = c("mpg", "gear", "cyl"))
  set3$variable &lt;- factor(set3$variable, levels = c("vs", "mpg", "drat"))
  
  # Make plots
  plot1 &lt;- ggplot(set1, aes(x = variable, y = value)) + ylim(0, 35) + geom_boxplot()
  plot2 &lt;- ggplot(set2, aes(x = variable, y = value)) + ylim(0, 35) + geom_boxplot()
  plot3 &lt;- ggplot(set3, aes(x = variable, y = value)) + ylim(0, 35) + geom_boxplot()
  
  grid.arrange(plot1, plot2, plot3, ncol = 3)
  </code></pre>
  
  <p>Here is the example of the plot:</p>
  
  <p><img src="https://i.stack.imgur.com/zYKvG.png" alt="Example plot"></p>