博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
matplotlib 制作原始数据的散点图
阅读量:4211 次
发布时间:2019-05-26

本文共 1119 字,大约阅读时间需要 3 分钟。

import numpy as npimport matplotlib.pyplot as pltreturnMat=np.array([[1,2],[3,4]])fig=plt.figure()ax=fig.add_subplot(111)#ax.scatter(returnMat[:,1],returnMat[:,2])#绘制颜色,大小不同的点classLabelVector=[1,2]ax.scatter(returnMat[:,1],returnMat[:,2],15.0*array(classLabelVector),15.0*array(classLabelVector))plt.show()

样例2:

#-*- coding=UTF-8 -*-#adaboost 算法import numpy as npdef loadSimpleData():    datMat = np.matrix([[1., 2.1],                     [2., 1.1],                     [1.3, 1.],                     [1., 1.],                     [2., 1.]])    classLabels = [1.0, 1.0, -1.0, -1.0, 1.0]    return datMat, classLabelsdataMat,classLabels=loadSimpleData()c=np.hstack((dataMat,np.mat(classLabels).T))b=[examle[:2] for examle in np.array(c) if examle[2]==1.0]b=np.array(b)print b[:,1]d=[examle[:,:2] for examle in c if examle[:,2]==-1.0]e=np.array(d)e= np.array(e.reshape(2,2))import numpy as npimport matplotlib.pyplot as pltreturnMat=np.array([[1,2],[3,4],[5,6]])fig=plt.figure()ax=fig.add_subplot(111)#ax.scatter(returnMat[:,1],returnMat[:,2])#绘制颜色,大小不同的点ax.scatter(b[:,0],b[:,1],14)ax.scatter(e[:,0],e[:,1],13)plt.show()

这里写图片描述

你可能感兴趣的文章
几种典型的反病毒技术:特征码技术、覆盖法技术等
查看>>
Software Security Testing软件安全测试
查看>>
SQL注入漏洞全接触--进阶篇
查看>>
SQL注入漏洞全接触--高级篇
查看>>
SQL注入法攻击一日通
查看>>
论文浅尝 | 通过共享表示和结构化预测进行事件和事件时序关系的联合抽取
查看>>
论文浅尝 | 融合多粒度信息和外部语言知识的中文关系抽取
查看>>
论文浅尝 | GMNN: Graph Markov Neural Networks
查看>>
廖雪峰Python教程 学习笔记3 hello.py
查看>>
从内核看epoll的实现(基于5.9.9)
查看>>
python与正则表达式
查看>>
安装.Net Framework 4.7.2时出现“不受信任提供程序信任的根证书中终止”的解决方法
查看>>
input type=“button“与input type=“submit“的区别
查看>>
解决Github代码下载慢问题!
查看>>
1.idea中Maven创建项目及2.对idea中生命周期的理解3.pom文件夹下groupId、artifactId含义
查看>>
LeetCode-栈|双指针-42. 接雨水
查看>>
stdin,stdout,stderr详解
查看>>
Linux文件和设备编程
查看>>
文件描述符
查看>>
终端驱动程序:几个简单例子
查看>>