matplotlib.legend_handler
¶
默认图例处理程序。
强烈建议您阅读 legend guide 在此文档之前。
图例处理程序应为具有以下签名的可调用对象。::
legend_handler(legend, orig_handle, fontsize, handlebox)
图例 是传说本身, orig_handle 是原图, 字体大小 是以像素为单位的字体大小,以及 手提箱 是OffsetBox实例。在调用中,您应该创建相关的艺术家(使用 图例 和/或 orig_handle )把它们放进手提箱里。艺术家需要根据字体大小进行缩放(请注意,大小以像素为单位,即这是dpi缩放值)。
此模块包括使用以下方法从基类(handlerBase)派生的几个图例处理程序类的定义:
def legend_artist(self, legend, orig_handle, fontsize, handlebox)
-
class
matplotlib.legend_handler.
HandlerBase
(xpad=0.0, ypad=0.0, update_func=None)[源代码]¶ 默认图例处理程序的基类。
派生类旨在重写 create_artists 方法,该方法具有以下签名。::
def create_artists(self, legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans):
重写的方法需要创建符合给定维度(xdecent、ydescent、width、height)的给定转换的艺术家,如有必要,将按fontsize进行缩放。
-
legend_artist
(legend, orig_handle, fontsize, handlebox)[源代码]¶ 返回此handlerBase为给定的原始艺术家/句柄生成的艺术家。
参数: - 传奇 :
Legend
传说 正在为其创建图例艺术家的图例。
- orig_handle :
matplotlib.artist.Artist
或类似Matplotlib.Artist.Artist或类似产品 正在为其创建这些图例艺术家的对象。
- fontsize利息
字体大小(像素)。正在创建的艺术家应根据给定的字体大小进行缩放。
- 手提箱 :
matplotlib.offsetbox.OffsetBox
matplotlib.offsetbox.OffsetBox
为保存此图例项的艺术家而创建的框。艺术家创作于
legend_artist
方法必须添加到此方法内部的句柄框中。
- 传奇 :
-
-
class
matplotlib.legend_handler.
HandlerCircleCollection
(yoffsets=None, sizes=None, **kw)[源代码]¶ 汉德勒
CircleCollection
S参数: - numpoints利息
要在图例项中显示的点数。
- yoffsets浮点阵列
长度 点数 图例项中每个点的Y偏移列表。
笔记
任何其他关键字参数都提供给
HandlerNpoints
.
-
class
matplotlib.legend_handler.
HandlerErrorbar
(xerr_size=0.5, yerr_size=None, marker_pad=0.3, numpoints=None, **kw)[源代码]¶ 误差线处理程序。
参数: - marker_pad浮动
图例项中点之间的填充。
- numpoints利息
要在图例项中显示的点数。
笔记
任何其他关键字参数都提供给
HandlerNpoints
.
-
class
matplotlib.legend_handler.
HandlerLine2D
(marker_pad=0.3, numpoints=None, **kw)[源代码]¶ 汉德勒
Line2D
实例。参数: - marker_pad浮动
图例项中点之间的填充。
- numpoints利息
要在图例项中显示的点数。
笔记
任何其他关键字参数都提供给
HandlerNpoints
.
-
class
matplotlib.legend_handler.
HandlerLineCollection
(marker_pad=0.3, numpoints=None, **kw)[源代码]¶ 汉德勒
LineCollection
实例。参数: - marker_pad浮动
图例项中点之间的填充。
- numpoints利息
要在图例项中显示的点数。
笔记
任何其他关键字参数都提供给
HandlerNpoints
.
-
class
matplotlib.legend_handler.
HandlerNpoints
(marker_pad=0.3, numpoints=None, **kw)[源代码]¶ 显示的图例处理程序 点数 图例项中的点。
参数: - marker_pad浮动
图例项中点之间的填充。
- numpoints利息
要在图例项中显示的点数。
笔记
任何其他关键字参数都提供给
HandlerBase
.
-
class
matplotlib.legend_handler.
HandlerNpointsYoffsets
(numpoints=None, yoffsets=None, **kw)[源代码]¶ 显示的图例处理程序 点数 并允许它们在y方向上单独偏移。
参数: - numpoints利息
要在图例项中显示的点数。
- yoffsets浮点阵列
长度 点数 图例项中每个点的Y偏移列表。
笔记
任何其他关键字参数都提供给
HandlerNpoints
.
-
class
matplotlib.legend_handler.
HandlerPatch
(patch_func=None, **kw)[源代码]¶ 汉德勒
Patch
实例。参数: - patch_func可调用,可选
创建图例关键艺术家的函数。 patch_func 应该有签名:
def patch_func(legend=legend, orig_handle=orig_handle, xdescent=xdescent, ydescent=ydescent, width=width, height=height, fontsize=fontsize)
随后,被创作的艺术家将
update_prop
方法,并将应用适当的转换。
笔记
任何其他关键字参数都提供给
HandlerBase
.
-
class
matplotlib.legend_handler.
HandlerPathCollection
(yoffsets=None, sizes=None, **kw)[源代码]¶ 汉德勒
PathCollection
s、 它们被scatter
.参数: - numpoints利息
要在图例项中显示的点数。
- yoffsets浮点阵列
长度 点数 图例项中每个点的Y偏移列表。
笔记
任何其他关键字参数都提供给
HandlerNpoints
.
-
class
matplotlib.legend_handler.
HandlerPolyCollection
(xpad=0.0, ypad=0.0, update_func=None)[源代码]¶ 汉德勒
PolyCollection
用于fill_between
和stackplot
.
-
class
matplotlib.legend_handler.
HandlerRegularPolyCollection
(yoffsets=None, sizes=None, **kw)[源代码]¶ 汉德勒
RegularPolyCollection
S参数: - numpoints利息
要在图例项中显示的点数。
- yoffsets浮点阵列
长度 点数 图例项中每个点的Y偏移列表。
笔记
任何其他关键字参数都提供给
HandlerNpoints
.
-
class
matplotlib.legend_handler.
HandlerStem
(marker_pad=0.3, numpoints=None, bottom=None, yoffsets=None, **kw)[源代码]¶ 绘图处理程序
stem
.参数: - marker_pad浮点,默认值:0.3
图例项中点之间的填充。
- numpoints可选的
要在图例项中显示的点数。
- bottom可选浮动
- yoffsets浮动数组,可选
长度 点数 图例项中每个点的Y偏移列表。
笔记
任何其他关键字参数都提供给
HandlerNpointsYoffsets
.
-
class
matplotlib.legend_handler.
HandlerTuple
(ndivide=1, pad=None, **kwargs)[源代码]¶ 元组的处理程序。
额外的夸克将通过
HandlerBase
.参数: - ndivideint,默认值:1
要将图例区域划分为的节数。如果没有,则使用输入元组的长度。
- pad : float, default:
rcParams["legend.borderpad"]
(default:0.4
)浮动,默认值: 以字体大小的分数为单位填充。