I am trying to adjust the edges around the markers in my legend. Currently my code looks like this

import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(15,10))
lri_map.plot(column= '30', 
           ax= ax, 
           scheme = 'NaturalBreaks', 
             cmap = 'Reds', 
             edgecolor = 'black',
            linewidth = 0.5, 

           missing_kwds = {
               'color' : 'lightgrey',
               'hatch': '////' ,
               'label' : 'Missing Values'


           legend_kwds={'loc': (0.05, 0.2), 'fontsize' : 10, 'facecolor' : 'white', 'edgecolor': 'white' },


Where lrimap is a GeoDataFrame. I produce the following graph: output produced my code

I would love to have an edge (line) around the markers in the legend, however it seems that by default this is turned off. Is there any way to add a small black line around the markers (it becomes otherwise hard to see the light red marker)? Somehow it does work for the missing data marker...


Sorry for being slow here, just came across this! Try:

for legend_handle in ax.get_legend().legendHandles:  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.