title: Seaborn: overlay scatterplot on top of boxplot
body: <p>I want to overlay a simple scatterplot on top of my boxplot. When I plot the two plots separately, everything is fine:</p>
  <p><a href="https://i.stack.imgur.com/4L9Ny.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4L9Ny.png" alt="boxplot solo" /></a>
  <a href="https://i.stack.imgur.com/CxSnU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CxSnU.png" alt="scatterplot solo" /></a></p>
  <p>But when I try to combine them, it almost looks like x-values of the scatterplot are all being divided by 2:</p>
  <p><a href="https://i.stack.imgur.com/SC52i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SC52i.png" alt="together" /></a></p>
  <p>I'm pretty sure it's because the boxplot treats the x-axis values as categorical (even though they are floats in my DataFrame), while the scatterplot treats them as continuous. But I don't know what the solution is. Here is the code I am using:</p>
  <pre><code>sns.scatterplot(data=old_data, x=&quot;x-axis&quot;, y=&quot;y-axis&quot;, s=200, color=&quot;red&quot;, label=&quot;Old Data&quot;)
  sns.boxplot(data=new_data, x=&quot;x-axis&quot;, y=&quot;y-axis&quot;, color=&quot;blue&quot;)
  plt.plot([], [], label=&quot;New Data&quot;, color='blue') # this just adds the boxplot label to the legend
  plt.legend()
  </code></pre>
  <p><strong>Bonus question:</strong> if you know how to add the boxplot label to the legend in a better way, I would love to hear about it.</p>