Every line of 'matplotlib legend position' 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
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)
244 def legend(pos): 245 return partial(adjustColumn, {'legend.orientation': pos}, all, all)
34 def size_legend(size): 35 return plt.Line2D([0],[0], color='black', marker='o', linestyle='None', markersize=size**.5)
1565 def set_label_position(self, position): 1566 """ 1567 Set the label position (top or bottom) 1568 1569 ACCEPTS: [ 'top' | 'bottom' ] 1570 """ 1571 assert position == 'top' or position == 'bottom' 1572 if position == 'top': 1573 self.label.set_verticalalignment('baseline') 1574 else: 1575 self.label.set_verticalalignment('top') 1576 self.label_position=position
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)
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)
84 def tweak_legend(): 85 plt.gca().get_legend().texts[0].set_size("xx-small")
198 def plotLegends(self): 199 if not self._legend:return 200 if not len(self._legendList):return 201 loc = (1.01, 0.0) 202 labelsep = 0.015 203 drawframe = True 204 fontproperties = FontProperties(size=10) 205 if len(self._legendList) > 14: 206 drawframe = False 207 if matplotlib_version < '0.99.0': 208 fontproperties = FontProperties(size=8) 209 loc = (1.05, -0.2) 210 else: 211 if len(self._legendList) < 18: 212 #drawframe = True 213 loc = (1.01, 0.0) 214 elif len(self._legendList) < 25: 215 loc = (1.05, 0.0) 216 fontproperties = FontProperties(size=8) 217 elif len(self._legendList) < 28: 218 loc = (1.05, 0.0) 219 fontproperties = FontProperties(size=6) 220 else: 221 loc = (1.05, -0.1) 222 fontproperties = FontProperties(size=6) 223 224 if matplotlib_version < '0.99.0': 225 legend = self.ax.legend(self._legendList, 226 loc = loc, 227 prop = fontproperties, 228 labelsep = labelsep, 229 pad = 0.15) 230 else: 231 legend = self.ax.legend(self._legendList, 232 loc = loc, 233 prop = fontproperties, 234 labelspacing = labelsep, 235 borderpad = 0.15) 236 legend.draw_frame(drawframe)