栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Matplotlib图例的箭头

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Matplotlib图例的箭头

您可以添加任意艺人传说命令,如解释在这里

import matplotlib.pyplot as pltf = plt.figure()arrow = plt.arrow(0, 0, 0.5, 0.6, 'dummy',label='My label')plt.legend([arrow,], ['My label',])

箭头美术师不允许使用标记参数,因此您需要做一些额外的手动修改,以替换图例中的标记。

编辑

要获得自定义标记,您需要定义自己的标记

handler_map
。下面的代码是在启发的例子在这里:

from matplotlib.legend_handler import HandlerPatchimport matplotlib.patches as mpatchesdef make_legend_arrow(legend, orig_handle,xdescent, ydescent,width, height, fontsize):    p = mpatches.FancyArrow(0, 0.5*height, width, 0, length_includes_head=True, head_width=0.75*height )    return pf = plt.figure(figsize=(10,6))arrow = plt.arrow(0,0, 0.5, 0.6, 'dummy', label='My label', )plt.legend([arrow], ['My label'], handler_map={mpatches.FancyArrow : HandlerPatch(patch_func=make_legend_arrow),         })


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/662676.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号