matplotlib散点图
我们常用的统计图如下:

1、学会绘制散点图
一个小demo:
假设通过爬虫你获取到了北京2016年3,10月份每天白天的最高气温(分别位于列表a,b),那么此时如何寻找出气温和随时间(天)变化的某种规律?
a = [11,17,16,11,12,11,12,6,6,7,8,9,12,15,14,17,18,21,16,17,20,14,15,15,15,19,21,22,22,22,23]
b = [26,26,28,19,21,17,16,19,18,20,20,19,22,23,17,20,21,20,22,15,11,15,5,13,17,10,11,13,12,13,6]
数据来源: http://lishi.tianqi.com/beijing/index.html
import matplotlib.pyplot as plt
# 3月份
y_3 = [11, 17, 16, 11, 12, 11, 12, 6, 6, 7, 8, 9, 12, 15, 14, 17, 18, 21, 16, 17, 20,
14, 15, 15, 15, 19, 21, 22, 22, 22, 23]
x_3 = range(1, 32)
# 10月份
y_10 = [26, 26, 28, 19, 21, 17, 16, 19, 18, 20, 20, 19, 22, 23, 17,
20, 21, 20, 22, 15, 11, 15, 5, 13, 17, 10, 11, 13, 12, 13, 6]
x_10 = range(51, 82)
# 设置图形大小
plt.figure(figsize=(20, 8), dpi=80)
# 使用scatter绘制散点图
plt.scatter(x_3, y_3, label="March")
plt.scatter(x_10, y_10, label="October")
# 调整x轴
x = list(x_3)+list(x_10)
_xtick_label = ["3月{}日".format(i) for i in x_3]
_xtick_label += ["10月{}日".format(i-50) for i in x_10]
plt.xticks(x[::3], _xtick_label[::3], fontproperties="SimSun", rotation=45)
# 添加描述信息
plt.xlabel("时间", fontproperties="SimSun")
plt.ylabel("温度", fontproperties="SimSun")
plt.title("北京2016", fontproperties="SimSun")
# 添加图例
plt.legend()
# 展示
plt.show()

使用散点图的场景:
- 不同条件(维度)之间的内在关联关系
- 观察数据的离散聚合程度
matplotlib散点图的更多相关文章
- matplotlib 散点图scatter
最近开始学习python编程,遇到scatter函数,感觉里面的参数不知道什么意思于是查资料,最后总结如下: 1.scatter函数原型 2.其中散点的形状参数marker如下: 3.其中颜色参数c如 ...
- matplotlib散点图笔记
定义: 由一组不连续的点完成的图形 散点图: 包含正相关性,负相关性和不相关性. 散点图生成函数: plt.scatter(x,y) 演示代码如下: import numpy as np import ...
- Matplotlib散点图、条形图、直方图-02
对比常用统计图 折线图: 特点:能够显示数据的变化趋势,反映事物的变化情况.(变化) 直方图: 特点:绘制连续性的数据,展示一组或者多组数据的分布情况(统计) 条形图: 特点:绘制离散的数据,能够一眼 ...
- Python 绘图与可视化 matplotlib 散点图、numpy模块的random()
效果: 代码: def scatter_curve(): # plt.subplot(1,1,1) n=1024 X=np.random.normal(0,1,n) Y=np.random.norma ...
- matplotlib 散点图
一.特点 离散的数据,查看分布规律,走向趋势 二.使用 1.核心 plt.scatter(x, y) # x为x轴的数据,可迭代对象,必须是数字 # y为y轴的数据,可迭代对象,必须是数字 # x和y ...
- Matplotlib 饼图
章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...
- Matplotlib 多个图形
章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...
- Matplotlib 图形绘制
章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...
- Matplotlib 安装
章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...
随机推荐
- vue父组件中调用子组件的方法
Vue项目中如何在父组件中直接调用子组件的方法: 方案一:通过ref直接调用子组件的方法: //父组件中 <template> <div> <Button @click= ...
- 使用Python来临时启动端口,用来做安全时候的扫描用
root用户:mkdir /home/aicccd /home/aicc/nohup python -m SimpleHTTPServer 8060 &netstat -antp|grep 8 ...
- C# 获取应用程序内存
double usedMemory = 0; Process p = Process.GetProcesses().Where(x => x.ProcessName.Co ...
- Elaticsearch基础概念
概述 elaticsearch是一个分布式的搜索引擎,它可以实现各种复杂的数据类型实现近实时的搜索功能,无论是结构化还是非结构化的数据,都能使用elaticsearch存储并且可以快速搜索.elati ...
- JS HTML5仿微信朋友圈特效
完美! 图片相册翻页可定位在第几张,右上角可关闭. 源代码下载地址: 链接: https://pan.baidu.com/s/1o7PA7wu 密码: asyt
- 安装redis3.0.5
首先在官网下载redis-3.0.5.tar.gz 在某一个要安装redis的目录下输入命令 tar xzf redis-3.0.5.tar.gz 实现解压缩 进入解压缩后的redis目录 输入mak ...
- 鸿蒙内核源码分析(进程通讯篇) | 九种进程间通讯方式速揽 | 百篇博客分析OpenHarmony源码 | v28.03
百篇博客系列篇.本篇为: v28.xx 鸿蒙内核源码分析(进程通讯篇) | 九种进程间通讯方式速揽 | 51.c.h .o 进程通讯相关篇为: v26.xx 鸿蒙内核源码分析(自旋锁篇) | 自旋锁当 ...
- FastAPI(39)- 使用 CORS 解决跨域问题
同源策略 https://www.cnblogs.com/poloyy/p/15345184.html CORS https://www.cnblogs.com/poloyy/p/15345871.h ...
- LaTeX Vscode 配置
安装:https://www.latexstudio.net/archives/51801.html LaTeX 安装 & 宏包升级 & 入门:https://blog.csdn.ne ...
- FastAPI(45)- JSONResponse
背景 创建 FastAPI 路径操作函数时,通常可以从中返回任何数据:字典.列表.Pydantic 模型.数据库模型等 默认情况下,FastAPI 会使用 jsonable_encoder 自动将该返 ...