matplotlib绘图基础--2
来源:互联网 发布:淘宝店访客突然少了 编辑:程序博客网 时间:2024/06/06 14:08
紧接着上一篇
用三种线条表示三种正弦趋势
In [6]: t = np.arange(0,2.5,0.1)
In [7]: y1 = map(math.sin,math.pi*t)
In [8]: y2 =map(math.sin,math.pi*t+math.pi/2)
In [9]: y3 =map(math.sin,math.pi*t-math.pi/2)
In [10]: plt.plot(t,y1,'b--',t,y2,'g',t,y3,'r--')
使用kwargs
组成图表的各个对象有很多用以描述它们特点的属性。这些属性均有默认值,但可以用关键字参数(keyword kwargs)设置
定义
matplotlib.pyplot.plot(*args,**kwargs)
设置linewidth关键字参数,可以改变线条的粗细
plt.plot([1,2,4,2,1,0,1,2,1,4],linewidth=2)
处理多个figure和Axes对象
使用subplot函数将图形分为不同的区域
类似In[10]的这种写法,是在输入完一行以后按”Ctrl+ Enter”来实现的换行,这样可以使这四行代码一同执行。
此处将图形分为了上下两部分来绘制,我们还可以把图形分为左右两个子图。subplot()函数传递进去的参数应分别为121和122。
t = np.arange(0.,1.,0.05)
y1 = np.sin(2*np.pi*t)
y2 = np.cos(2*np.pi*t)
plt.subplot(121)
plt.plot(t,y1,'b-.')
plt.subplot(122)
plt.plot(t,y2,'r--')
为图表添加更多元素
添加文本
axis函数用来制定坐标轴的取值范围
title函数用来设置图像标题
xlabel函数用来设置x轴的轴标签
ylabel函数用来设置y轴的轴标签
In[21]:plt.axis([0,5,0,20])
...: plt.title("This is title")
...: plt.xlabel("This is x label")
...: plt.ylabel("This is y lable")
...:plt.plot([1,2,3,4],[1,4,9,16],'ro
- matplotlib绘图基础--2
- matplotlib 2D绘图基础
- matplotlib绘图基础
- matplotlib绘图基础
- matplotlib绘图基础
- matplotlib绘图基础
- matplotlib绘图基础--1
- matplotlib绘图基础--3
- matplotlib绘图基础
- matplotlib绘图基础--笔记
- [053]matplotlib绘图基础
- Matplotlib基础绘图函数示例
- matplotlib学习之绘图基础
- matplotlib学习之绘图基础
- matplotlib学习之绘图基础
- matplotlib学习之绘图基础
- matplotlib学习之绘图基础
- Python3.绘图基础matplotlib.pyplot
- Could not execute JDBC batch update; SQL [delete from role where roleId=?]; constraint [null]; neste
- 用Mesos分布式架构进行工作
- qt国际化翻译
- 调用EAS单据转换规则(BOTP),生成下游单据
- 技术盛会 I/O,apple WWDC,Build
- matplotlib绘图基础--2
- UART接口介绍
- Java加密与解密学习记录06-数字签名算法
- wampsever3.0.6-apache2.4.23修改文件路径问题
- GeoHash原理分析
- Xcode下载地址大全
- 神奇的MySQL客户端MyCLI
- 你刚吃的兰州牛肉面_背后就藏着大数据
- mllib 假设检验