python学习日记25matplotlib

本文是关于Python的matplotlib绘图库的学习笔记,介绍了matplotlib的基本概念、pyplot与pylab的区别、plt.plot的使用、子图 subplot 的创建、交互模式、图形风格设置、配置文件目录以及Line段简化等知识点,旨在帮助读者掌握matplotlib的使用技巧。
摘要由CSDN通过智能技术生成

matplotlib,是一款风格近似matlab,面向对象的画图工具包

一:
入门教程
https://matplotlib.org/tutorials/introductory/usage.html#sphx-glr-tutorials-introductory-usage-py

顶层top of the hierarchy,是由 matplotlib.pyplot模块提供的state-machine environment
下一层是面向对象接口
import matplotlib.pyplot as plt
import numpy as np

画图时各部分名称
在这里插入图片描述

Figure,整个图像
Axes,每幅子图的坐标系范围内,一个plot,
一个子图包含两个轴Axis,该轴可以设置最大值最小值范围,
用Axes的方法set_xlim() and set_ylim()
图名设置:set_title()
坐标轴名设置:set_xlabel() set_ylabel())
Axis,坐标轴
Artist,每个figure是一个artist,可以画在Canvas帆布上
Input:np.array

二:
Matplotlib, pyplot and pylab的关系
Matplotlib是整个包; matplotlib.pyplot 是其中的模块; pylab 是装matplotlib时同时装上的另外的模块
pylab是将pyplot和numpy结合在一起,不建议使用,引起命名空间污染。

三:plt.plot
第一次调用 plt.plot会自动创建 figure and axes。后续调用plt.plot会复用前面的设置。

四:plt.subplot
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplots.html?highlight=subplots#matplotlib.pyplot.subplots

subplots:

matplotlib.pyplot.subplots(
nrows=1, ncols=1,
sharex=False, sharey=False,
squeeze=True,
subplot_kw=None,
gridspec_kw=None,
**fig_kw)[source]

Create a figure and a set of

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值