title: For scatterplot with matplotlib how to include in the legend gradient for dot size and colour?
body: <p>I create two scatterplots with <code>matplotlib</code> in python with this code, the data for the code is <a href="https://drive.google.com/file/d/118TPUVVBIG8yNCJlFCIfboe4Ue0vIclD/view?usp=sharing" rel="nofollow noreferrer">here</a>:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from matplotlib.colors import Normalize
  
  fig = plt.figure(figsize=(20,12))
  ax1 = fig.add_subplot(111)
  ax3 = ax1.twinx()
  
  norm = Normalize(vmin=0.95*min(arr), vmax=1.05*max(arr))
  
  ax1.scatter(x, y1, s=20, c=arr, cmap='Blues_r', norm=norm, marker='x', label='bla1')
  ax3.scatter(x, y2, s=(20*(1.1-arr))**3.5, c=arr, cmap='Reds_r', norm=norm, marker='^', label='bla1')
  </code></pre>
  
  <p>The created fig. looks like this:
  <a href="https://i.stack.imgur.com/gB1aX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gB1aX.png" alt="enter image description here"></a></p>
  
  <p>So, the dot size (in ax3) and the dot colour (in ax1 and ax3) are taken from arrays containing floats with all kinds of values in the range [0,1]. My question: <strong>How do I create a legend that displays the corresponding y-values for, let's say 5 different dot sizes and 5 different colour nuances?</strong>  </p>
  
  <p>I would like the legend to look like in the figure below (source <a href="https://blogs.oii.ox.ac.uk/bright/2014/08/12/point-size-legends-in-matplotlib-and-basemap-plots/" rel="nofollow noreferrer">here</a>), but with the colour bar and size bar put into a single legend, if possible. Thanks for suggestions and code!</p>
  
  <p><a href="https://i.stack.imgur.com/USDfS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/USDfS.png" alt="enter image description here"></a></p>