Every line of 'legend position matplotlib' 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.
251 def 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
244 def legend(pos): 245 return partial(adjustColumn, {'legend.orientation': pos}, all, all)
325 def 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)
2589 def _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. 2592 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. 2608 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)
34 def size_legend(size): 35 return plt.Line2D([0],[0], color='black', marker='o', linestyle='None', markersize=size**.5)
561 def legend(self, *args, **kwargs): 562 this_axes = self 563 class SmithHandlerLine2D(HandlerLine2D): 564 def create_artists(self, legend, orig_handle, 565 xdescent, ydescent, width, height, fontsize, 566 trans): 567 legline, legline_marker = HandlerLine2D.create_artists(self, legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans) 568 569 if hasattr(orig_handle, "_markerhacked"): 570 this_axes._hack_linedraw(legline_marker, True) 571 return [legline, legline_marker] 572 return Axes.legend(self, *args, handler_map={Line2D : SmithHandlerLine2D()}, **kwargs)
415 def figlegend(handles, labels, loc, **kwargs): 416 """ 417 Place a legend in the figure. 418 419 *labels* 420 a sequence of strings 421 422 *handles* 423 a sequence of :class:`~matplotlib.lines.Line2D` or 424 :class:`~matplotlib.patches.Patch` instances 425 426 *loc* 427 can be a string or an integer specifying the legend 428 location 429 430 A :class:`matplotlib.legend.Legend` instance is returned. 431 432 Example:: 433 434 figlegend( (line1, line2, line3), 435 ('label1', 'label2', 'label3'), 436 'upper right' ) 437 438 .. seealso:: 439 440 :func:`~matplotlib.pyplot.legend` 441 442 """ 443 l = gcf().legend(handles, labels, loc, **kwargs) 444 draw_if_interactive() 445 return l