matplotlib的基本用法(四)——设置legend图例
来源:互联网 发布:js 按键监听 编辑:程序博客网 时间:2024/05/21 17:35
文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
本文主要是关于matplotlib的一些基本用法。
- Demo
import matplotlib.pyplot as pltimport numpy as np# 绘制普通图像x = np.linspace(-1, 1, 50)y1 = 2 * x + 1y2 = x**2plt.figure()# 在绘制时设置lable, 逗号是必须的l1, = plt.plot(x, y1, label = 'line')l2, = plt.plot(x, y2, label = 'parabola', color = 'red', linewidth = 1.0, linestyle = '--')# 设置坐标轴的取值范围plt.xlim((-1, 1))plt.ylim((0, 2))# 设置坐标轴的lableplt.xlabel('X axis')plt.ylabel('Y axis')# 设置x坐标轴刻度, 原来为0.25, 修改后为0.5plt.xticks(np.linspace(-1, 1, 5))# 设置y坐标轴刻度及标签, $$是设置字体plt.yticks([0, 0.5], ['$minimum$', 'normal'])# 设置legendplt.legend(handles = [l1, l2,], labels = ['a', 'b'], loc = 'best')plt.show()
- 结果
1 0
- matplotlib的基本用法(四)——设置legend图例
- matplotlib命令与格式:图例legend语法及设置
- ggplot2-设置图例(legend)
- matplotlib的基本用法(二)——设置坐标轴
- matplotlib的基本用法(六)——设置坐标轴label
- Matplotlib设置图例字体大小
- ggplot2--legend图例的修改
- ggplot2--legend图例的修改
- matplotlib——对坐标的控制,加图例注释
- legend图例
- matplotlib的基本用法(一)——figure的使用
- matplotlib的基本用法(三)——调整坐标轴
- matplotlib的基本用法(五)——添加annotation
- matplotlib的基本用法(七)——绘制散点图
- matplotlib的基本用法(八)——绘制柱状图
- matplotlib的基本用法(十)——绘制Image
- matplotlib的基本用法(十五)——主次坐标轴
- matplotlib的基本用法(十六)——创建动画
- HTTP Status 500
- unity中BringWindowToFront和dragWindow的用法
- sql 语句as用法
- LeetCode 208 Implement Trie(实现字典树)
- 属性和普通变量使用增强赋值语句时的差异
- matplotlib的基本用法(四)——设置legend图例
- Dagger 2从浅到深(一)
- Oracle那些进程帮我们做些什么
- 线程、线程池总结
- PonyCar体验感受
- javascript的内置对象string对象总结
- 简单配置spring+springmvc+mybatis之整合
- 第三讲、Linux常用命令
- 游戏内聊天垃圾文本检测