使用matplotlib画散点图的方法
作者:baidu_36161077 时间:2022-07-30 20:49:54
如下所示:
import matplotlib.pyplot as plt
import numpy as np
a = np.array([1,2,3,4])
b = np.array([1,2,3,4])
c = np.array([2,3,4,5])
d = np.array([2,3,4,5])
'''
figure的作用新建绘画窗口,独立显示绘画的图片
figsize 表示新建绘画窗口的大小
dpi是分辨率
'''
plt.figure(figsize = (8,5),dpi = 80)
'''
这个比较重要,需要重点掌握,参数有r,c,n三个参数
使用这个函数的重点是将多个图像画在同一个绘画窗口.
r 表示行数
c 表示列行
n 表示第几个
'''
plt.subplot(2,1,1)#表示一个绘画窗口下建立两个子图,选择第一个作为绘画图
plt.scatter(a,b,c = 'r')
plt.scatter(c,d,c = 'b')
#将会在第一个图中画出两种颜色不一样的点
plt.subplot(2,1,2)
plt.scatter(a,b,c = 'black')
plt.show()
来源:https://blog.csdn.net/baidu_36161077/article/details/74560576
标签:matplotlib,散点图
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python函数返回值实例分析
2022-06-23 06:59:07
python安装及变量名介绍详解
2023-09-24 19:23:20
![](https://img.aspxhome.com/file/2023/7/77587_0s.png)
python删除服务器文件代码示例
2023-07-26 15:44:08
![](https://img.aspxhome.com/file/2023/4/113154_0s.png)
python @property的用法及含义全面解析
2023-04-06 00:42:28
在python中实现对list求和及求积
2022-05-28 15:02:16
python自动化八大定位元素讲解
2022-02-24 21:46:03
![](https://img.aspxhome.com/file/2023/9/118659_0s.png)
Python创建文件和追加文件内容实例
2021-03-15 04:38:09
python 如何读、写、解析CSV文件
2022-09-21 13:59:33
![](https://img.aspxhome.com/file/2023/7/97627_0s.jpg)
python SocketServer源码深入解读
2023-04-15 18:38:44
![](https://img.aspxhome.com/file/2023/9/110589_0s.png)
python selenium 获取标签的属性值、内容、状态方法
2021-03-12 23:02:46
SQL Server 2008主要功能在兼容性上的问题
2009-03-25 16:43:00
pycharm 中mark directory as exclude的用法详解
2021-02-27 05:24:07
python 自动监控最新邮件并读取的操作
2023-02-04 12:58:51
PHP实现web socket长链接流程详解
2023-05-27 23:44:39
python教程十行代码教你语音转文字QQ微信聊天
2024-01-03 09:06:54
![](https://img.aspxhome.com/file/2023/8/127278_0s.jpg)
python自动统计zabbix系统监控覆盖率的示例代码
2023-11-14 08:23:03
在keras中实现查看其训练loss值
2021-03-05 05:29:44
关于python 读取csv最快的Datatable的用法,你都学会了吗
2022-02-22 20:38:32
![](https://img.aspxhome.com/file/2023/5/101585_0s.jpg)
Python使用微信SDK实现的微信支付功能示例
2022-09-22 00:19:41
简单实现python数独游戏
2023-06-21 15:24:22