python中引用matplotlib画图的几个常用命令及基本步骤
来源:互联网 发布:jsp中java调用js变量 编辑:程序博客网 时间:2024/06/02 02:10
①引包:import matplotlib.pyplot as plt;
②创建画布:fig = plt.figure();
③添加分区:ax = fig.add_subplot(311) #三个数字分别代表行、列及本图所处位置;
④ax..axis([-5,5,0,1]) #设置x轴最小、最大值,y轴最小、最大值;
⑤ax.scatter(xcord1,ycord1, s=30, c='red', marker='s') #用于画散点图;
⑥ax.plot(x, y) #用于画线图;
⑦plt.title(“this is a title”) #图形添加标题;
⑧plt.xlabel('x')、plt.ylabel('y') #分别对坐标轴添加标题
⑨plt.show() #显示图形;
完毕!!!
plot作图的几种特殊情况:
①、单列表,例如:n = [1,2,5,6]
ax.plot(n)作出的图以列表元素的索引为x轴,索引对应值为y轴显示,如下图:
②二维列表,例如m = [ [2,3], [5,5], [7,6] ]
ax.plot(m)作出的图以第一维列表元素的索引为x轴,第二维列表的第一个值和第二个值组成两个单列表(分别为:[2,5,7]和[3,5,6]),如下图:
③、矩阵作图与第②种情况类似。
阅读全文
0 0
- python中引用matplotlib画图的几个常用命令及基本步骤
- Python中matplotlib画图
- Python中matplotlib包的scatter画图函数错误情况及解决办法
- python的画图模块matplotlib
- 用python的matplotlib画图
- python中matplotlib和pandas画图
- python中matplotlib画图中文不能显示
- matplotlib基本画图示例
- Matplotlib--基本画图
- python 的 matplotlib画图 画曲线图
- Python matplotlib画图的中文显示问题
- 用python的matplotlib画图总结1
- 安装Python的画图工具matplotlib
- Python matplotlib 画图相关
- python matplotlib 画图简介
- 使用python matplotlib画图
- Python Matplotlib画图示例
- python使用matplotlib画图
- Android 国际化
- 微信小程序获取openid
- json串 无法转对象
- UVa11825 Hackers' Crackdown
- 欢迎使用CSDN-markdown编辑器
- python中引用matplotlib画图的几个常用命令及基本步骤
- js中的事件委托或是事件代理详解
- 【Python精华】100个Python练手小程序
- StringUtils中 isNotEmpty 和isNotBlank的区别
- 在Widora上玩MQTT (widora)
- 添加权限
- VS生成解决方案提示“已经添加了具有相同键的项”
- Django 403错误
- js加载三级菜单(附带加载日期)