title: Bar and line graphs overlaying on same figure, containing groups, and by another group
body: <p>I am attempting to create a figure that essentially has a bar graph corresponding to one group and a line graph for another group, but where there are two groups within each of the formerly described groups. I have tried various ways of using twoway and binscatter but have not been able to achieve what I would like.</p>
  <p>I am including a picture of what I would like to create:</p>
  <p><a href="https://i.stack.imgur.com/Pc0HD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pc0HD.png" alt="enter image description here" /></a></p>
  <p>(On the y-axis is &quot;cost&quot; which both the line graphs and bar graphs refer to. From a data visualization standpoint I would personally use either 4 line graphs or even 4 bar graphs, but 2 lines, and 2 sets of bars are what is desired).</p>
  <p>I imagine it might take some reshaping, but it might not. If anyone has any leads, I would definitely appreciate it. If color could be left to the user's desire, that would be even better. Although I think the data is shaped so that one could create the graph &quot;automatically&quot; by referring to the categories, it might be possible to reshape the data and use county-year as the categorical variable.</p>
  <p>The code to develop the dataset (thanks to Nick Cox for developing a superior version of my example code):</p>
  <pre><code>clear
  set seed 1234 
  set obs 16
  g year = cond(_n &gt; 8, 2010, 2000) 
  bysort year: g country = cond(_n &gt; 4, &quot;China&quot;, &quot;USA&quot;)  
  bysort year country : gen month = _n 
  g cost = runiform(0, 100)
  </code></pre>