一、特点

离散的数据,查看分布规律,走向趋势

二、使用

1、核心

plt.scatter(x, y)
# x为x轴的数据,可迭代对象,必须是数字
# y为y轴的数据,可迭代对象,必须是数字
# x和y必须一一对应

2、例子

注意:在设置x轴或y轴刻度时,ticks和labes的值要一一对应

from matplotlib import pyplot as plt
from matplotlib import font_manager 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] # 设置中文
my_font = font_manager.FontProperties(fname='C:\Windows\Fonts\msyh.ttc') x_a = range(1, 32)
x_b = range(51, 82)
# 设置图形大小
plt.figure(figsize=(20, 8), dpi=80) # 绘图
plt.scatter(x_a, a, label="3月份")
plt.scatter(x_b, b, label="4月份") # 定制x轴的刻度和label
_x = list(x_a) + list(x_b)
x_labels = ["3月{}日".format(i) for i in x_a]
x_labels += ["11月{}日".format(i) for i in x_a]
plt.xticks(_x[::3], x_labels[::3], fontproperties=my_font, rotation=45) # 添加描述
plt.xlabel("日期", fontproperties=my_font)
plt.ylabel("温度 单位(℃)", fontproperties=my_font)
plt.title("3月份和11月份的温度", fontproperties=my_font) # 添加图例
plt.legend(prop=my_font)
# 展示图片
plt.show()

matplotlib 散点图的更多相关文章

  1. matplotlib 散点图scatter

    最近开始学习python编程,遇到scatter函数,感觉里面的参数不知道什么意思于是查资料,最后总结如下: 1.scatter函数原型 2.其中散点的形状参数marker如下: 3.其中颜色参数c如 ...

  2. matplotlib散点图笔记

    定义: 由一组不连续的点完成的图形 散点图: 包含正相关性,负相关性和不相关性. 散点图生成函数: plt.scatter(x,y) 演示代码如下: import numpy as np import ...

  3. Matplotlib散点图、条形图、直方图-02

    对比常用统计图 折线图: 特点:能够显示数据的变化趋势,反映事物的变化情况.(变化) 直方图: 特点:绘制连续性的数据,展示一组或者多组数据的分布情况(统计) 条形图: 特点:绘制离散的数据,能够一眼 ...

  4. matplotlib散点图

    我们常用的统计图如下: 1.学会绘制散点图 一个小demo: 假设通过爬虫你获取到了北京2016年3,10月份每天白天的最高气温(分别位于列表a,b),那么此时如何寻找出气温和随时间(天)变化的某种规 ...

  5. 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 ...

  6. Matplotlib 饼图

    章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...

  7. Matplotlib 多个图形

    章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...

  8. Matplotlib 图形绘制

    章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...

  9. Matplotlib 安装

    章节 Matplotlib 安装 Matplotlib 入门 Matplotlib 基本概念 Matplotlib 图形绘制 Matplotlib 多个图形 Matplotlib 其他类型图形 Mat ...

随机推荐

  1. linux一个例子驱动

    我们介绍的驱动称为 short (Simple Hardware Operations and Raw Tests). 所有它做 的是读和写几个 8-位 端口, 从你在加载时选择的开始. 缺省地, 它 ...

  2. Spring Security 学习笔记-信道过滤器

    信道过滤器主要职责是拦截不合规则的http请求,比如规定只能通过https访问资源,那么信道拦截器做相应的拦截处理,把http请求重定向为https请求,https请求则不做任何处理. 配置方式参照: ...

  3. hive查询中文乱码问题

    问题1. hue中中文字符乱码问题,重现步骤如下 create external table test_1_txt (id int, name varchar(100))  location '/tm ...

  4. 《HelloGitHub》第 45 期

    兴趣是最好的老师,HelloGitHub 就是帮你找到兴趣! 简介 分享 GitHub 上有趣.入门级的开源项目. 这是一个面向编程新手.热爱编程.对开源社区感兴趣 人群的月刊,月刊的内容包括:各种编 ...

  5. 【原创】http请求中加号被替换为空格?源码背后的秘密

    这是why技术的第**20**篇原创文章![在这里插入图片描述](https://user-gold-cdn.xitu.io/2019/12/30/16f550eb82e10eff?w=900& ...

  6. 最长无重复子串问题 leetcode 3

    一.代码及注释 class Solution { public: int lengthOfLongestSubstring(string s) { int n = s.size(); //字符串的长度 ...

  7. The sixth day of Crawler learning

    爬取我爱竞赛网的大量数据 首先获取每一种比赛信息的分类链接 def get_type_url(url):    web_data = requests.get(web_url)    soup = B ...

  8. DEVOPS技术实践_20:串联多个job执行

    在jenkins可能会有战役中场景,就是在一个job执行完之后,把这个执行结果作为另一个job的执行条件 比如A执行完,如果A执行成功,则执行B,如果失败则执行C 1 前期准备 A任务 import ...

  9. 20191017-5 alpha week 2/2 Scrum立会报告+燃尽图 04

    此作业要求参见https://edu.cnblogs.com/campus/nenu/2019fall/homework/9801 小组名称:“组长”组 组长:杨天宇 组员:魏新,罗杨美慧,王歆瑶,徐 ...

  10. 关于KMP的一点思考

    关于KMP的一点思考 KMP的\(next\)数组的性质很精妙,有必要开一个坑学习一下 Part 1 啥是next \(next[i]\)表示对于\(pre_i\)这个字符串,这个抠出来的字符串本身后 ...