ggplot2: facets: different axis limits and free space
<p>I want to display two dimensions in my data, (1) reporting entity in different facets and (2) country associated to the data point on the x-axis. The problem is that the country dimension includes a "total", which is a lot higher than all of the individual values, so I would need an own axis limit for that.</p>

<p>My solution was to try another facetting dimension, but I could not get it working and looking nicely at the same time. Consider the following dummy data:</p>

<pre><code>id &lt;- c(1,1,1,1,1,1,2,2,2,2,2,2)
country &lt;- c("US","US","UK","World","World","World","US","US","UK","World","World","World")
value &lt;- c(150,40,100,1000,1100,1500,5,10,20,150,200,120)
# + some other dimensions
mydat &lt;- data.frame(id,country,value)

   id country value
1   1      US   150
2   1      US    40
3   1      UK   100
4   1   World  1000
5   1   World  1100
6   1   World  1500
7   2      US     5
8   2      US    10
9   2      UK    20
10  2   World   150
11  2   World   200
12  2   World   120
</code></pre>

<p>If I use a facet grid to display a world total, the axis limit is forced for the other countries as well:</p>

<pre><code>mydat$breakdown &lt;- mydat$country == "World"

ggplot(mydat) + aes(x=country,y=value) + geom_point() + 
  facet_grid(id ~ breakdown,scales = "free",space = "free_x") + 
  theme(strip.text.x = element_blank() , strip.background = element_blank(),
        plot.margin = unit( c(0,0,0,0) , units = "lines" ) )
</code></pre>

<p>(the last part of the plot is just to remove the additional strip).</p>

<p><a href="https://i.stack.imgur.com/PIvzF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PIvzF.png" alt="facet grid plot"></a></p>

<p>If I use a facet wrap, it does give me different axis limits for each plot, but then I cannot pass the <code>space = "free_x"</code> argument, meaning that the single column for the total will consume the same space as the entire country overview, which looks ugly for data sets with many countries:</p>

<pre><code>ggplot(mydat) + aes(x=country,y=value) + geom_point() + 
  facet_wrap(id ~ breakdown,scales = "free")
</code></pre>

<p><a href="https://i.stack.imgur.com/izOQh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/izOQh.png" alt="facet wrap plot"></a></p>

<p>There are several threads here which ask similar questions, but none of the answers helped me to achieve this yet.</p>

<p><a href="https://stackoverflow.com/questions/21937127/different-axis-limits-per-facet-in-ggplot2">Different axis limits per facet in ggplot2</a></p>

<p><a href="https://stackoverflow.com/questions/18819333/is-it-yet-possible-to-have-different-axis-breaks-limits-for-individual-facets">Is it yet possible to have different axis breaks / limits for individual facets in ggplot with free scale?</a></p>

<p><a href="https://stackoverflow.com/questions/18046051/setting-individual-axis-limits-with-facet-wrap-and-scales-free-in-ggplot2">Setting individual axis limits with facet_wrap and scales = &quot;free&quot; in ggplot2</a></p>