title: Scatter plot marker size and legend, markers = area, but how do I get legend labels = diameter?
body: <p>I have been a long time viewer of your questions and answers as I learn python.  I have hit a snag in making some figures for a project I am working on.</p>
  <p>I am making a figure detailing properties of small bodies in our solar system (asteroids and dwarf planets).</p>
  <p>I have successfully created a scatter plot of the small bodies as functions of their orbital period and eccentricity.  Each point marker is scaled in size to the area of the object (diameter**2).  I have created a legend showing these sizes, particularly how they compare to the dwarf planets.</p>
  <p>My question:  I do want the marker sizes to scale with the area of the asteroid (as they currently are), but I would like the labels for the marker sizes in the legend to show the diameter.  I am not sure how to have the labels and marker sizes be different relations.  Marker size proportional to diameter**2 and label proportional to diameter.</p>
  <p>Here is the code I have so far and the resulting figure:</p>
  <p>Small version of my datafile:</p>
  <pre><code>spkid   full_name   pdes    name    diameter    extent  rot_per GM  e   a   q   i   ad  per per.y
  2002060   2060 Chiron (1977 UB) 2060    Chiron  166     5.918       0.3766  13.71   8.544   6.92    18.87   1.85E+04    50.7
  2005145   5145 Pholus (1992 AD) 5145    Pholus  190     9.98        0.5705  20.33   8.733   24.63   31.93   3.35E+04    91.7
  2005335   5335 Damocles (1991 DA)   5335    Damocles                    0.8658  11.86   1.591   61.61   22.13   1.49E+04    40.8
  2007066   7066 Nessus (1993 HA2)    7066    Nessus                  0.5157  24.66   11.945  15.63   37.38   4.47E+04    122
  2008405   8405 Asbolus (1995 GO)    8405    Asbolus 66      8.9351      0.6211  18.04   6.834   17.61   29.24   2.80E+04    76.6
  2010199  10199 Chariklo (1997 CU26) 10199   Chariklo    302     7.004       0.1677  15.82   13.17   23.36   18.48   2.30E+04    62.9
  2010370  10370 Hylonome (1995 DW2)  10370   Hylonome                    0.2439  25.12   18.993  4.14    31.24   4.60E+04    126
  2015504  15504 (1999 RG33)  15504                       0.774   9.368   2.117   34.96   16.62   1.05E+04    28.7
  2015760  15760 Albion (1992 QB1)    15760   Albion                  0.075   44.17   40.861  2.18    47.49   1.07E+05    294
  2015788  15788 (1993 SB)    15788                       0.3212  39.4    26.747  1.94    52.06   9.03E+04    247
  2015789  15789 (1993 SC)    15789       328             0.1886  39.74   32.241  5.15    47.23   9.15E+04    250
  2015807  15807 (1994 GV9)   15807                       0.0586  43.58   41.031  0.56    46.14   1.05E+05    288
  2015809  15809 (1994 JS)    15809                       0.2231  42.54   33.05   14.05   52.03   1.01E+05    277
  2015810  15810 Arawn (1994 JR1) 15810   Arawn           5.49        0.12    39.61   34.861  3.8 44.37   9.11E+04    249
  2015820  15820 (1994 TB)    15820               6       0.3193  39.6    26.961  12.14   52.25   9.10E+04    249
  2015836  15836 (1995 DA2)   15836                       0.072   36.18   33.576  6.57    38.79   7.95E+04    218
  2015874  15874 (1996 TL66)  15874               12      0.5824  83.73   34.971  23.96   132.5   2.80E+05    766
  2015875  15875 (1996 TP66)  15875                       0.3325  39.4    26.304  5.7 52.5    9.03E+04    247
  2015883  15883 (1997 CR29)  15883                       0.2131  46.76   36.797  19.19   56.73   1.17E+05    320
  2016684  16684 (1994 JQ1)   16684                       0.0523  44.12   41.811  3.75    46.43   1.07E+05    293
  2019255  19255 (1994 VK8)   19255               4.7     0.0307  42.7    41.388  1.48    44.01   1.02E+05    279
  2019299  19299 (1996 SZ4)   19299                       0.2603  39.66   29.34   4.73    49.99   9.12E+04    250
  2019308  19308 (1996 TO66)  19308               7.92        0.1156  43.53   38.499  27.34   48.56   1.05E+05    287
  2019521  19521 Chaos (1998 WH24)    19521   Chaos                   0.1016  45.67   41.03   12.02   50.31   1.13E+05    309
  </code></pre>
  <p><a href="https://i.stack.imgur.com/MODo4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MODo4.png" alt="" /></a></p>
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  import pandas as pd
  import matplotlib.ticker as tk
  
  class MyLocator(tk.AutoMinorLocator):
      def __init__(self, n=4):
          super().__init__(n=n)
  tk.AutoMinorLocator = MyLocator
  
  fig, ax = plt.subplots(figsize=[15,10])
  
  #df = pd.read_csv('sbdb_query_results.csv')
  #df = pd.read_csv('sbdb_query_results_ast_gt_07yr.csv')
  #df = pd.read_csv('sbdb_query_results_ast_lt_1000yr.csv')
  df = pd.read_csv('sbdb_query_results_ast_gt_20yr_lt_1000yr.csv')
  df.info(1)     
  
  
  factor = 100.
  
  dia = df['diameter']/factor
  dia = dia[~np.isnan(dia)]
  
  scatter = ax.scatter(df['per.y'], df['e'], marker='.', color='blue', s=dia**2, zorder=2)#relative to Neptune
  
  plt.xscale('log')
  #plt.yscale('log')
  plt.minorticks_on()
  plt.tick_params(which='minor', length=2, color='r')
  
  a = [2.76596,39.236193, 43.335, 45.791, 67.6681]
  p = [4.61, 247.92065, 284.81, 307.54, 557.56]
  e = [7.976e-2, 0.24421, 0.188740, 0.159, 0.44177]
  i = [10.587, 17.150, 28.190, 28.960, 44.187]
  name = ['Ceres', 'Pluto', 'Haumea', 'Makemake', 'Eris']
  y = [1, 1, 1, 1, 1]
  rcolor = ['orange','violet','cyan','red','lime']
  
  plt.scatter(4.61,7.976e-2,marker='o',s=(939.4/factor)**2, color='orange',zorder=1, label='Ceres')
  plt.scatter(247.92065,0.24421,marker='o',s=(2376/factor)**2, color='violet',zorder=1, label='Pluto')
  plt.scatter(284.81,0.18874,marker='o',s=(1595.2/factor)**2, color='cyan',zorder=1, label='Haumea')
  plt.scatter(307.54,0.159,marker='o',s=(1429.4/factor)**2, color='red',zorder=1, label='Makemake')
  plt.scatter(557.56,0.44177,marker='o',s=(2326/factor)**2, color='lime',zorder=1, label='Eris')
  
  legend1 = ax.legend(loc='lower left', scatterpoints=1, fontsize=14)
  legend1.legendHandles[0]._sizes = [50]
  legend1.legendHandles[1]._sizes = [50]
  legend1.legendHandles[2]._sizes = [50]
  legend1.legendHandles[3]._sizes = [50]
  legend1.legendHandles[4]._sizes = [50]
  ax.add_artist(legend1)
  legend1.set_title('Dwarf Planets',prop={'size':16})
  
  
  handles, labels = scatter.legend_elements(prop=&quot;sizes&quot;, num = 10, alpha=0.6)
  legend2 = ax.legend(handles, labels, loc=&quot;upper left&quot;, fontsize=14, bbox_to_anchor=(0.0,0.25,0.25,0.75), labelspacing = 1.5, borderpad=1.5)
  legend2.set_title('Diameter (km)',prop={'size':16})
  
  
  plt.xlabel(&quot;Period of Revolution (years)&quot;)
  plt.xlim(1,1000)
  plt.ylabel(&quot;Eccentricity&quot;)
  plt.ylim(0,1)
  plt.title('Small Bodies in Solar System')
  
  plt.show()
  </code></pre>