3 examples of 'matplotlib legend outside' in Python

Every line of 'matplotlib legend outside' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
325def legend(*args, **kwargs):
326 kwargs.setdefault('framealpha', 0.2)
327 try:
328 plt.legend(*args, **kwargs)
329 except:
330 warnings.warn("framealpha not effective")
331 kwargs.pop('framealpha')
332 plt.legend(*args, **kwargs)
251def legend(self, ax, lines=(), labels=(), legend_loc="best"):
252 ax.legend(
253 lines,
254 labels,
255 title=None,
256 loc=legend_loc,
257 frameon=False,
258 ncol=1,
259 labelspacing=0.5,
260 columnspacing=1,
261 borderpad=1,
262 handlelength=2,
263 fontsize=12,
264 )
265 return ax
2589def _paint_colorbar_legend(ax, values, cmap, legend_kwargs):
2590 """
2591 Creates a legend and attaches it to the axis. Meant to be used when a ``legend=True`` parameter is passed.
2593 Parameters
2594 ----------
2595 ax : matplotlib.Axes instance
2596 The ``matplotlib.Axes`` instance on which a legend is being painted.
2597 values : list
2598 A list of values being plotted. May be either a list of int types or a list of unique entities in the
2599 data column (e.g. as generated via ``numpy.unique(data)``. This parameter is meant to be the same as that
2600 returned by the ``_discrete_colorize`` method.
2601 cmap : ``matplotlib.cm`` instance
2602 The `matplotlib` colormap instance which will be used to colorize the legend entries. This should be the
2603 same one used for colorizing the plot's geometries.
2604 legend_kwargs : dict
2605 Keyword arguments which will be passed to the matplotlib legend instance on initialization. This parameter
2606 is provided to allow fine-tuning of legend placement at the top level of a plot method, as legends are very
2607 finicky.
2609 Returns
2610 -------
2611 None.
2612 """
2613 if not legend_kwargs: legend_kwargs = dict()
2614 cmap.set_array(values)
2615 plt.gcf().colorbar(cmap, ax=ax, **legend_kwargs)

Related snippets