title: Add small histogram inside plot area of another plot
body: <p>Is there a way to add a histogram inside the plot area of another plot, but independent of the "base" plot's coordinate system? In my case, I want to add a histogram as a legend to a choropleth map (the histogram would show the number of regions that fall in each class), but the question could just as easily apply to any plot. For example</p>
  
  <pre><code>plot(1:10)
  rect(1, 7, 4, 9, col="gray")
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/GJYdC.png" alt="enter image description here"></p>
  
  <p>Could I make a histogram appear where the gray rectangle is in the above plot? Currently, if I try to create a histogram of the series 1:10, it appears using the coordinate system set by the scatterplot, and I can't figure out how (or whether it is possible) to reposition it and resize it to appear in the top left.</p>
  
  <pre><code>plot(1:10)
  hist(1:10, col="gray90", add=TRUE)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/THvFN.png" alt="enter image description here"></p>