显示图例(legend)
来源:互联网 发布:成都旧时光唱片淘宝网 编辑:程序博客网 时间:2024/05/04 18:28
参数:
loc(设置图例显示的位置)
'best' : 0, (only implemented for axes legends)(自适应方式)'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,
ncol(设置列的数量,使显示扁平化,当要表示的线段特别多的时候会有用)
使用pyplot的方式
#!/usr/bin/python#coding: utf-8import numpy as np import matplotlib.pyplot as plt x = np.arange(1, 11, 1)# plt.plot(x, x * 2, label = "First")# plt.plot(x, x * 3, label = "Second")# plt.plot(x, x * 4, label = "Third")# # loc 设置显示的位置,0是自适应# # ncol 设置显示的列数# plt.legend(loc = 0, ncol = 2)# 也可以这样指定labellabel = ["First", "Second", "Third"]plt.plot(x, x * 2)plt.plot(x, x * 3)plt.plot(x, x * 4)plt.legend(label, loc = 0, ncol = 2)plt.show()
使用面向对象的方式
#!/usr/bin/python#coding: utf-8import numpy as np import matplotlib.pyplot as plt x = np.arange(1, 11, 1)fig = plt.figure()ax = fig.add_subplot(111)# 面向对象的方式中有三种显示label的方法# # 第一种# # l后面不加逗号会出错,一定要注意# l, = ax.plot(x, x * 2)# l.set_label("Demo")# ax.legend(loc = 0)# 第二种# ax.plot(x, x * 2, label = "Demo")# ax.legend(loc = 0)# 第三种ax.plot(x, x * 2)ax.legend(['Demo'], loc = 0)plt.show()
0 0
- 显示图例(legend)
- legend图例
- echarts的legend图例的显示与隐藏(legend图例进入页面显示的个数)
- ggplot2--Legend(图例操作)
- HightChart图例(Legend)
- ggplot2-设置图例(legend)
- Arcgis 图例 esri.dijit.legend Legend widget
- ggplot2--legend图例的修改
- highcharts legend 饼图 图例位置
- ggplot2--legend图例的修改
- echarts 修改图例legend颜色
- 十一、基础教程-图例(Legend)
- [Ext JS 4] Extjs 图表 Legend(图例)的分行与分列显示
- Highcharts翻译系列六:legend 图例选项
- Matlab中图例注释函数legend详解
- Highcharts翻译系列:legend 图例选项
- Highcharts翻译系列六:legend 图例选项
- MPAndroidchart 教程:图例 Legend(七)
- Win10 下安装PhotoShop CS6
- Leetcode在线编程evaluate-reverse-polish-notation
- h5: canvas如何设置高度和宽度
- Linux驱动之构造简单运行模块
- [kuangbin带你飞]专题四 最短路练习 C
- 显示图例(legend)
- 普通01背包
- “开源”将成为物联网开发生态链的标准
- HTTPS协议之SSL证书
- 区块链学习笔记(二)EthereumJ的编译及Idea开发环境搭建
- RxJava+okhttp+Retrofit+Mvp 的封装
- Win10 下安装Office 2013
- Linux通过 Docker 可以托管 .NET Core啦!
- HTTPS证书生成原理和部署细节