1、scatter函数原型

2、其中散点的形状参数marker如下:

3、其中颜色参数c如下:

4、基本的使用方法如下:

#导入必要的模块
import numpy as np
import matplotlib.pyplot as plt
#产生测试数据
x = np.arange(1,10)
y = x
fig = plt.figure()
ax1 = fig.add_subplot(111)
#设置标题
ax1.set_title('Scatter Plot')
#设置X轴标签
plt.xlabel('X')
#设置Y轴标签
plt.ylabel('Y')
#画散点图
ax1.scatter(x,y,c = 'r',marker = 'o')
#设置图标
plt.legend('x1')
#显示所画的图
plt.show()
结果如下:

5、当scatter后面参数中数组的使用方法,如s,当s是同x大小的数组,表示x中的每个点对应s中一个大小,其他如c,等用法一样,如下:

(1)、不同大小

#导入必要的模块
import numpy as np
import matplotlib.pyplot as plt
#产生测试数据
x = np.arange(1,10)
y = x
fig = plt.figure()
ax1 = fig.add_subplot(111)
#设置标题
ax1.set_title('Scatter Plot')
#设置X轴标签
plt.xlabel('X')
#设置Y轴标签
plt.ylabel('Y')
#画散点图
sValue = x*10
ax1.scatter(x,y,s=sValue,c='r',marker='x')
#设置图标
plt.legend('x1')
#显示所画的图
plt.show()

(2)、不同颜色

#导入必要的模块
import numpy as np
import matplotlib.pyplot as plt
#产生测试数据
x = np.arange(1,10)
y = x
fig = plt.figure()
ax1 = fig.add_subplot(111)
#设置标题
ax1.set_title('Scatter Plot')
#设置X轴标签
plt.xlabel('X')
#设置Y轴标签
plt.ylabel('Y')
#画散点图
cValue = ['r','y','g','b','r','y','g','b','r']
ax1.scatter(x,y,c=cValue,marker='s')
#设置图标
plt.legend('x1')
#显示所画的图
plt.show()

结果:

(3)、线宽linewidths

#导入必要的模块
import numpy as np
import matplotlib.pyplot as plt
#产生测试数据
x = np.arange(1,10)
y = x
fig = plt.figure()
ax1 = fig.add_subplot(111)
#设置标题
ax1.set_title('Scatter Plot')
#设置X轴标签
plt.xlabel('X')
#设置Y轴标签
plt.ylabel('Y')
#画散点图
lValue = x
ax1.scatter(x,y,c='r',s= 100,linewidths=lValue,marker='o')
#设置图标
plt.legend('x1')
#显示所画的图
plt.show()

最新文章

  1. Centos YUM 升级PHP
  2. ios 配置https
  3. 短链(ShortURL)的Java实现
  4. POJ1062昂贵的聘礼[最短路建模]
  5. apache struts 2 任意代码执行漏洞
  6. MySQL中varchar转int
  7. back(返回)键总结
  8. Visual Studio 中TODO List的使用
  9. Java从入门到精通(一)
  10. YII 小部件 yii小部件查看方法 小物件做的表单
  11. php测试时不出现错误信息
  12. Android 自己主动化測试之------ Monkey工具
  13. mapxtreme C# 完美车辆动态轨迹展示
  14. Prefix the choice with ! to persist it to bower.json ? Answer (问你选择哪个1,2,3.........)
  15. 原生javascript选项卡
  16. nginx 502 bad gateway 问题处理集锦
  17. POJ1088(记忆搜索加dp)
  18. MonkeyRunner_批处理执行py文件
  19. mongodb学习-练习实例
  20. Aerospike系列:6:AerospikeTools & Utilities

热门文章

  1. poj2387- Til the Cows Come Home(最短路)
  2. C#语言-NPOI.dll导入Excel功能的实现
  3. spring websocket集群问题的简单记录
  4. MDP中值函数的求解
  5. 决策树算法(ID3)
  6. Git 统计提交代码行数
  7. luoguP3185 [HNOI2007]分裂游戏 枚举 + 博弈论
  8. Uva 12889 One-Two-Three
  9. ZeptoLab Code Rush 2015 B. Om Nom and Dark Park DFS
  10. codecombat js