莫烦-matplotlib学习笔记(四)
来源:互联网 发布:失业金数据公布时间 编辑:程序博客网 时间:2024/05/29 04:07
参考莫烦教学视频https://morvanzhou.github.io/tutorials/data-manipulation/plt/2-5-lagend/
import matplotlib.pyplot as pltimport numpy as npx = np.linspace(-3, 3, 50)y1 = 2*x + 1y2 = x**2plt.figure()# set x limitsplt.xlim((-1, 2))plt.ylim((-2, 3))# set new sticksnew_sticks = np.linspace(-1, 2, 5)plt.xticks(new_sticks)# set tick labelsplt.yticks([-2, -1.8, -1, 1.22, 3], [r'$really\ bad$', r'$bad$', r'$normal$', r'$good$', r'$really\ good$'])#设置两条线的类型等信息(蓝色实线与红色虚线).l1, = plt.plot(x, y1, label='linear line')l2, = plt.plot(x, y2, color='red', linewidth=1.0, linestyle='--', label='square line')plt.legend(loc='best')# plt.legend(handles=[l1, l2], labels=['up', 'down'], loc='best')# the "," is very important in here l1, = plt... and l2, = plt... for this step"""legend( handles=(line1, line2, line3), labels=('label1', 'label2', 'label3'), 'upper right') The *loc* location codes are:: 'best' : 0, (currently not supported for figure 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,"""plt.show()
阅读全文
0 0
- 莫烦-matplotlib学习笔记(四)
- Matplotlib学习笔记(四)
- 莫烦-matplotlib学习笔记(一)
- 莫烦-matplotlib学习笔记(二)
- 莫烦-matplotlib学习笔记(三)
- Matplotlib学习笔记(一)
- Matplotlib学习笔记(二)
- Matplotlib学习笔记(三)
- Matplotlib学习笔记(五)
- matplotlib 学习笔记(一)
- matplotlib 学习笔记(二)
- Python学习笔记(一)--- Matplotlib
- 机器学习笔记(一):matplotlib入门
- 机器学习笔记(二):matplotlib基础
- matplotlib学习笔记
- Matplotlib学习笔记
- matplotlib学习笔记 (1)
- Matplotlib 学习笔记
- CNCF启动Kubernetes一致性认证计划,32家云系统及平台厂商获得通过
- C++中默认构造函数中数据成员的初始化
- Designing Next Generation Web Projects with CSS3.pdf 英文原版 免费下载
- 171116之公司制度
- 油田问题 UVA 572
- 莫烦-matplotlib学习笔记(四)
- c++为函数设置动态参数
- 在Eclipse上安装插件springsource-tool-suite详解,完美不报错!以及yml无自动提示?
- 线性代数的本质(笔记二)
- Java 集合框架面试问题集锦
- Jump Start CSS.pdf 英文原版 免费下载
- yml
- 欢迎使用CSDN-markdown编辑器
- 【证明】放球问题