parameters: (self, ax, cmap, **legend_kwargs)
docstring: Add a legend to the plot.
docstring_summary: Add a legend to the plot.
docstring_tokens: Add a legend to the plot .
function: def add_legend(self, ax, cmap, **legend_kwargs):
          """Add a legend to the plot."""
          leg = create_legend(ax, cmap, np.arange(cmap.N), self.common_unique)
  
          extra = dict(bbox_to_anchor=(0.9, 0.05, 0.1, 0.1), ncol=cmap.N / 2,
                       mode='scale', fancybox=False, shadow=False, fontsize=3.0,
                       columnspacing=1.0, loc='center right', markerscale=0.7,
                       framealpha=1.0, borderpad=0.5, handleheight=0.5,
                       frameon=True)
          legend_kwargs.update(extra)
  
          ax.legend(handles=leg, **legend_kwargs)
function_tokens: def add_legend ( self , ax , cmap , * * legend_kwargs ) : leg = create_legend ( ax , cmap , np . arange ( cmap . N ) , self . common_unique ) extra = dict ( bbox_to_anchor = ( 0.9 , 0.05 , 0.1 , 0.1 ) , ncol = cmap . N / 2 , mode = 'scale' , fancybox = False , shadow = False , fontsize = 3.0 , columnspacing = 1.0 , loc = 'center right' , markerscale = 0.7 , framealpha = 1.0 , borderpad = 0.5 , handleheight = 0.5 , frameon = True ) legend_kwargs . update ( extra ) ax . legend ( handles = leg , * * legend_kwargs )