matplotlib中plot的使用

matplotlib库是python中实现数据处理与展示的非常优秀的类库 
它提供了超过100多种的图像处理和现实方法 
官网展示的一些样例 
matplotlib定义了各种可视化的类 
matplotlib.pyplot是绘制各种图形的命令子库,相当于快捷方式

通常情况下我们使用它的别名plt 
import matplotlib.pyplot as plt 
一些常用方法: 
plt.plot(x,y,format_string,**kwargs) 
x轴数据,y轴数据,format_string控制曲线的格式字串 
format_string 由颜色字符,风格字符,和标记字符 
 matplotlib中plot的使用
 
 matplotlib中plot的使用
可以这样使用 
plt.plot([1,2,3,6],[4,5,8,1],’g-s’) 
**kwards: 
color 颜色 
linestyle 线条样式 
marker 标记风格 
markerfacecolor 标记颜色 
markersize 标记大小 等等 
plt.plot([1,2,3,6],[4,5,8,1],’-s’,color = ‘#ff0000’) 
plt.plot([5,4,3,2,1]) 
plt.plot([0,2,4,6,8],[5,8,6,3,1]) //传入两个列表时第一个列表为x轴的值

plt.axis([-1,10,0,6]) //axis 函数为x轴范围【-1,10】,y【0,6】 
plt.ylabel(‘sdf’) 
plt.savefig(‘test’,dpi=600) //图像保存,默认为png格式 
plt.show() 
plt.subplot(3,2,4) // 将图像分割为3行,两列,选择第四个区域

 

实例代码

import matplotlib.pyplot as plt
#plt.plot([1,2,3],[4,5,6],'ro')
#plt.plot([1,2,3],[4,5,6],'r:+')
plt.plot([1,2,3],[4,5,6],'r:*')
plt.show()


--------------------- 
作者:L花自飘零 
来源:CSDN 
原文:https://blog.csdn.net/u014539580/article/details/78207537 
版权声明:本文为博主原创文章,转载请附上博文链接!

上一篇:Matplotlib库(一)


下一篇:使用python内置库matplotlib,实现折线图的绘制