课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
15分钟

Legend 类

  1. matplotlib.legend.Legend是图例类,它的基类是matplotlib.artist.Artist。其构造函数为:  Legend(parent, handles, labels, loc=None, numpoints=None, markerscale =None, markerfirst=True, scatterpoints=None,  scatteryoffsets=None, prop=None, fontsize=None, borderpad =None, labelspacing=None, handlelength=None,  handleheight=None, handletextpad=None, borderaxespad =None, columnspacing=None, ncol=1, mode=None,  fancybox=None, shadow=None, title=None, framealpha =None, bbox_to_anchor=None, bbox_transform=None,  frameon=None, handler_map=None) 其关键字参数为:
  • parent:持有该legendartist
  • loc:图例的位置。其值可以为字符串或者数字:
    • best或0:自动计算
    • upper right或1: 右上角
    • upper left或2:上角
    • lower left或3:下角
    • lower right或4:右下角
    • right或5:右边
    • center left或6:中间偏左
    • center right或7:中间偏右
    • lower center或8:中间底部
    • upper center或9:中间顶部
    • center或10:正中央
  • handle:一个artist列表,添加这些artistlegend
  • lebels:一个字符串列表添加到legend
  • prop:字体属性
  • fontsize: 字体大小(只有prop未设置时有效)
  • markerscale: marker的缩放比例(相对于原始大小)
  • markerfirst: 如果为True,则marker放在label左侧;否则marker放在label右侧
  • numpoints: the number of points in the legend for line
  • scatterpoints: the number of points in the legend for scatter plot
  • scatteryoffsets: a list of offsets for scatter symbols in legend
  • frameon: if True, draw a frame around the legend. If None, use rc
  • fancybox: if True, draw a frame with a round fancybox. If None, use rc
  • shadow: if True, draw a shadow behind legend
  • framealpha: If not None, alpha channel for the frame.
  • ncol: number of columns
  • borderpad: the fractional whitespace inside the legend border
  • labelspacing: the vertical space between the legend entries
  • handlelength: the length of the legend handles
  • handleheight: the height of the legend handles
  • handletextpad: the pad between the legend handle and text
  • borderaxespad: the pad between the axes and legend border
  • columnspacing:the spacing between columns
  • title: 图例的标题
  • bbox_to_anchor: the bbox that the legend will be anchored.
  • bbox_transform: the transform for the bbox. transAxes if Noneloc a location code
  • 其他关键字参数用于设置属性

属性为:

  • 继承自Artist基类的属性: .alpha.animated.axes.clip_box、..clip_on.clip_path.contains.figure.gid.label.picker.transform.url.visible.zorder