title: Custom legend labels - geopandas.plot()
body: <p>A colleague and I have been trying to set custom legend labels, but so far have failed. Code and details below - any ideas much appreciated!</p>
  
  <p>Notebook: <a href="https://gist.github.com/claytonrsh/3a3fd878a8b935b3cf720fabf7187a11" rel="nofollow noreferrer">toy example uploaded here</a></p>
  
  <p>Goal: change default rate values used in the legend to corresponding percentage values</p>
  
  <p>Problem: cannot figure out how to access the legend object or pass <code>legend_kwds</code> to <code>geopandas.GeoDataFrame.plot()</code></p>
  
  <p>Data: <a href="https://gist.githubusercontent.com/claytonrsh/76313da528e1116a959d7401b8b7afed/raw/8247f2fcf3fb08aa1f3aa7b236fba3013602dc9d/kcmo_counties.geojson" rel="nofollow noreferrer">KCMO metro area counties</a></p>
  
  <p><strong>Excerpts from toy example</strong></p>
  
  <p>Step 1: read data</p>
  
  <pre><code># imports
  import geopandas as gpd
  import matplotlib.pyplot as plt
  %matplotlib inline
  # read data
  gdf = gpd.read_file('kcmo_counties.geojson')
  </code></pre>
  
  <p>Option 1 - get legend from <code>ax</code> as <a href="https://stackoverflow.com/questions/33762891/how-to-change-the-text-of-the-legend-of-a-choropleth-map-in-python">suggested here</a>:</p>
  
  <pre><code>ax = gdf.plot('val', legend=True)
  leg = ax.get_legend()
  print('legend object type: ' + str(type(leg))) # &lt;class NoneType&gt;
  plt.show()
  </code></pre>
  
  <p>Option 2: pass <code>legend_kwds</code> dictionary - I assume I'm doing something wrong here (and clearly don't fully understand the underlying details), but the <code>_doc_</code> from <a href="https://github.com/geopandas/geopandas/blob/master/geopandas/plotting.py" rel="nofollow noreferrer">Geopandas's plotting.py</a> - for which <a href="https://github.com/geopandas/geopandas/blob/master/geopandas/geodataframe.py" rel="nofollow noreferrer">GeoDataFrame.plot() is simply a wrapper</a> - does not appear to come through...</p>
  
  <pre><code># create number of tick marks in legend and set location to display them
  import numpy as np
  numpoints = 5
  leg_ticks = np.linspace(-1,1,numpoints)
  
  # create labels based on number of tickmarks
  leg_min = gdf['val'].min()
  leg_max = gdf['val'].max()
  leg_tick_labels = [str(round(x*100,1))+'%' for x in np.linspace(leg_min,leg_max,numpoints)]
  leg_kwds_dict = {'numpoints': numpoints, 'labels': leg_tick_labels}
  
  # error "Unknown property legend_kwds" when attempting it:
  f, ax = plt.subplots(1, figsize=(6,6))
  gdf.plot('val', legend=True, ax=ax, legend_kwds=leg_kwds_dict)
  </code></pre>
  
  <p><strong>UPDATE</strong>
  Just came across <a href="https://github.com/geopandas/geopandas/pull/434" rel="nofollow noreferrer">this conversation</a> on adding in <code>legend_kwds</code> - and this other <a href="https://github.com/geopandas/geopandas/issues/694" rel="nofollow noreferrer">bug?</a> which clearly states <code>legend_kwds</code> was not in most recent release of GeoPandas (v0.3.0). Presumably, that means we'll need to compile from the GitHub <code>master</code> source rather than installing with pip/conda...</p>