数据分析:Matplotlib

文章目录什么是 matplotlib为什么要学习matplotlib什么是matplotlibmatplotlib基本要点Matplotlib 常用设置(折线图)设置图片大小调整 x 轴或者 y 轴上的刻度设置中文显示常用的统计图散点图条形图单个条形图的绘制多个条形图绘制直方图普通直方图![在这里插入图片描述](https://img-blog.csdnimg.cn/201908261124179...
摘要由CSDN通过智能技术生成

什么是 matplotlib

为什么要学习matplotlib

  1. 能够将数据进可视化,更直观的呈现
  2. 是数据更加客观,更具说服力

什么是matplotlib

matplotlib:最流行的Python底层绘图库,主要做数据可视化图表,名字取材于MATLAB,模仿MATLAB构建

matplotlib基本要点

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

Matplotlib 常用设置(折线图)

在这里插入图片描述

设置图片大小

在这里插入图片描述

调整 x 轴或者 y 轴上的刻度

在这里插入图片描述

设置中文显示

在这里插入图片描述

常用的统计图

在这里插入图片描述

散点图

在这里插入图片描述

import random
from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties
"""
绘制10月和三月温度变化的散点图
"""

# 字体设置
myfont = FontProperties(fname="/usr/share/fonts/wqy-microhei/wqy-microhei.ttc", size=14)
titlefont = FontProperties(fname="/usr/share/fonts/wqy-microhei/wqy-microhei.ttc", size=25)

# x轴和Y轴数据
march_y = [random.randint(10, 20) for i in range(31)]
october_y = [random.randint(20, 30) for j in range(31)]
x = range(1, 32) # 1, 2, 3, ...31


# 设置图形大小
plt.figure(figsize=(10, 5), dpi=100)

# 绘制散点图
plt.subplot(2,  1,  1)
plt.scatter(x, march_y, )
# 调整刻度
_x3_labels = ["3月{}日".format(_) for _ in x]
# rotation: 旋转
plt.xticks(x[::3], labels=_x3_labels[::3], fontproperties=myfont, rotation=45)
# x, y和标题的说明
plt.xlabel("月份", fontproperties
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值