title: Relocating Alaska and Hawaii on thematic map of the USA with ggplot2
body: <p>I am trying to create a thematic map showing all 50 US states, but I am having trouble relocating Alaska and Hawaii in a reliable way. I have a couple of ideas but none of them work well. I will demonstrate them now.</p>
  <p>First we need to import the data; using the data in the <code>maps</code> package is not enough because it does not include Hawaii and Alaska.</p>
  <pre><code>setwd(tempdir())
  download.file(&quot;https://dl.dropbox.com/s/wl0z5rpygtowqbf/states_21basic.zip?dl=1&quot;, 
                &quot;usmapdata.zip&quot;, 
                method = &quot;curl&quot;)
  # This is a mirror of http://www.arcgis.com/home/item.html?
  # id=f7f805eb65eb4ab787a0a3e1116ca7e5
  unzip(&quot;usmapdata.zip&quot;)
  
  require(rgdal)
  all_states &lt;- readOGR(&quot;states_21basic/&quot;, &quot;states&quot;)
  
  require(ggplot2); require(maptools); require(rgeos); require(mapproj);
  all_states &lt;- fortify(all_states, region = &quot;STATE_NAME&quot;)
  </code></pre>
  <p>Now we define some plot aesthetics:</p>
  <pre><code>p &lt;- ggplot() + geom_polygon( 
    aes(x=long, y=lat, group = group, fill = as.numeric(as.factor(id))), 
    colour=&quot;white&quot;, size = 0.25
  ) + coord_map(projection=&quot;azequalarea&quot;) + 
  scale_fill_gradient(limits = c(1,50))
  </code></pre>
  <p>Now we remove all background etc so they don't clash when we overlap the non-contiguous states:</p>
  <pre><code>p &lt;-   p + theme(axis.line=element_blank(),
              axis.text.x=element_blank(),
              axis.text.y=element_blank(),
              axis.ticks=element_blank(),
              axis.title.x=element_blank(),
              axis.title.y=element_blank(),
              panel.background=element_blank(),
              panel.border=element_blank(),
              panel.grid.major=element_blank(),
              panel.grid.minor=element_blank(),
              plot.background=element_blank())
  </code></pre>
  <h2>Using viewports</h2>
  <p>The first idea I had was to use viewports:</p>
  <pre><code>AK &lt;- p %+% subset(all_states, id == &quot;Alaska&quot;) + theme(legend.position = &quot;none&quot;)
  HI &lt;- p %+% subset(all_states, id == &quot;Hawaii&quot;) + theme(legend.position = &quot;none&quot;)
  contiguous &lt;- p %+% subset(all_states, id != &quot;Alaska&quot; &amp; id != &quot;Hawaii&quot;)
  
  grid.newpage()
  vp &lt;- viewport(width = 1, height = 1)
  print(contiguous, vp = vp)
  subvp1 &lt;- viewport(width = 0.25, height = 0.25, x = 0.18, y = 0.33)
  print(AK, vp = subvp1)
  subvp2 &lt;- viewport(width = 0.12, height = 0.12, x = 0.32, y = 0.27)
  print(HI, vp = subvp2)
  </code></pre>
  <p><img src="https://i.stack.imgur.com/UytXg.png" alt="enter image description here" /></p>
  <p>This looks nice but it is not satisfactory because it is very sensitive to slight changes in the figure, for example resizing or changes in the size and shape of the legend.</p>
  <h2>Manually moving Alaska and Hawaii</h2>
  <pre><code>all_states_AKHImoved &lt;- within(all_states, {
    lat[id == &quot;Alaska&quot;] &lt;- lat[id == &quot;Alaska&quot;] - 45
    long[id == &quot;Alaska&quot;] &lt;- long[id == &quot;Alaska&quot;] + 40
    lat[id == &quot;Hawaii&quot;] &lt;- lat[id == &quot;Hawaii&quot;] + 0
    long[id == &quot;Hawaii&quot;] &lt;- long[id == &quot;Hawaii&quot;] + 70
  })
  p %+% all_states_AKHImoved
  </code></pre>
  <p><img src="https://i.stack.imgur.com/XwvZS.png" alt="enter image description here" /></p>
  <p>This is not satisfactory because Alaska is usually not to scale on most US maps so it looks very big. Also relocating Alaska and Hawaii changes the distortion introduced by the map projection.</p>
  <h2>Question</h2>
  <p>Does anyone have any better approaches?</p>