Skip to content

Commit

Permalink
update major classes
Browse files Browse the repository at this point in the history
  • Loading branch information
AIboy996 committed Mar 12, 2024
1 parent 064147c commit 53b9eb4
Show file tree
Hide file tree
Showing 46 changed files with 334 additions and 60 deletions.
2 changes: 1 addition & 1 deletion docs/About/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hide:
- [**Blog**](../Blog):博客板块,记录日常的博客。
- [**Python**](../Python):Python板块,包含基础、高级语法知识和各种库的使用。
- [**Project**](../Project):项目板块,本人的一些开源项目。
- [**Statistics**](../Statistics)统计学相关
- [**Statistics**](../Statistics)鄙人专业相关
- [**SomeMath**](../SomeMath):数学相关。
- [**PlayGround**](../Playground):用来调试mkdocs-material提供的markdown的扩展语法
- [**Tags**](../Tags/):👇
Expand Down
1 change: 0 additions & 1 deletion docs/Project/AirPrint-with-Python.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
title: 基于Python的AirPrint虚拟打印机
tags:
- python项目
- 开源项目
Expand Down
1 change: 0 additions & 1 deletion docs/Project/Course-Selection-System.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
title: 基于Django的选课系统
tags:
- Django
- python项目
Expand Down
1 change: 0 additions & 1 deletion docs/Project/plt-gallery.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
title: 基于PyScript的matplotlib画廊
tags:
- PyScript
- 开源项目
Expand Down
1 change: 0 additions & 1 deletion docs/Project/pymd.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
tags:
- python项目
- 开源项目
title: 基于Python的markdown渲染器
---

# pymd
Expand Down
1 change: 0 additions & 1 deletion docs/Project/qrq.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
tags:
- JavaScript
- 开源项目
title: chrome二维码生成扩展
---

# qrq
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
145 changes: 143 additions & 2 deletions docs/Python/ThirdPartyLibrary/matplotlib/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,148 @@ tags:
- matplotlib
hide:
- tags
- toc
---

# matplotlib
# matplotlib

## 简介

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. **Matplotlib makes easy things easy and hard things possible**.

加粗的这句话说的非常好,如果读者看过一些古老的Python教科书,一定会知道Python还有一个知名的绘画库:turtle,这是一个非常有趣的库但是非常难用,很简单的图也需要很复杂的代码才能画出来。相比之下,matplotlib真正做到了:简单的几句话就搞定,再复杂的图也能搞定。

咱也算一个统计人,下面这种分布图还是经常画的。R、MATLAB、Excel啥的都用过一点。个人觉得还是matplotlib更自由,画起来得心应手。
<figure markdown>
![](assets/2024-03-12-15-09-00.png){width=400}
<caption>直方图+盒子图</caption>
</figure>

像下面这种复杂的图,也能画(但我是没画过):

<figure markdown>
![](https://matplotlib.org/stable/_images/sphx_glr_sankey_rankine_001_2_00x.png){width=400}
</figure>

!!! question "为什么叫matplotlib"
Copy from [matplotlib history](https://matplotlib.org/stable/users/project/history.html)

Matplotlib is a library for making 2D plots of arrays in Python. Although it has **its origins in emulating the MATLAB graphics commands**, it is independent of MATLAB, and can be used in a Pythonic, object-oriented way. Although Matplotlib is written primarily in pure Python, it makes heavy use of NumPy and other extension code to provide good performance even for large arrays.
...

## 两套api
初学者可能会很迷惑的点就是matplotlib画图是有两套交互方式的(虽然本质上他们相同),我们之后也会分别介绍。
### [函数式:plt](./plt)
这种方式是最常见的,也是简单任务下最方便快捷的方式,缺点就是很多操作是不透明的、全局的,plt的处理方法可能和你预想的不同。

使用方法就是调用`matplotlib.pyplot`提供的各种api在默认的画布上绘制。
```python
import matplotlib.pyplot as plt
plt.plot(x, y)
plt.title("Sample plot")
plt.show()
```
### [面向对象式:axes](./subplots)
这种方式的自由度更高,可以手动控制`Figure``Axes`对象。
```python
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_title("Sample plot")
plt.show()
```
## 库的架构

```
Modules include:
:mod:`matplotlib.axes`
The `~.axes.Axes` class. Most pyplot functions are wrappers for
`~.axes.Axes` methods. The axes module is the highest level of OO
access to the library.
:mod:`matplotlib.figure`
The `.Figure` class.
:mod:`matplotlib.artist`
The `.Artist` base class for all classes that draw things.
:mod:`matplotlib.lines`
The `.Line2D` class for drawing lines and markers.
:mod:`matplotlib.patches`
Classes for drawing polygons.
:mod:`matplotlib.text`
The `.Text` and `.Annotation` classes.
:mod:`matplotlib.image`
The `.AxesImage` and `.FigureImage` classes.
:mod:`matplotlib.collections`
Classes for efficient drawing of groups of lines or polygons.
:mod:`matplotlib.colors`
Color specifications and making colormaps.
:mod:`matplotlib.cm`
Colormaps, and the `.ScalarMappable` mixin class for providing color
mapping functionality to other classes.
:mod:`matplotlib.ticker`
Calculation of tick mark locations and formatting of tick labels.
:mod:`matplotlib.backends`
A subpackage with modules for various GUI libraries and output formats.
The base matplotlib namespace includes:
`~matplotlib.rcParams`
Default configuration settings; their defaults may be overridden using
a :file:`matplotlibrc` file.
`~matplotlib.use`
Setting the Matplotlib backend. This should be called before any
figure is created, because it is not possible to switch between
different GUI backends after that.
The following environment variables can be used to customize the behavior:
:envvar:`MPLBACKEND`
This optional variable can be set to choose the Matplotlib backend. See
:ref:`what-is-a-backend`.
:envvar:`MPLCONFIGDIR`
This is the directory used to store user customizations to
Matplotlib, as well as some caches to improve performance. If
:envvar:`MPLCONFIGDIR` is not defined, :file:`{HOME}/.config/matplotlib`
and :file:`{HOME}/.cache/matplotlib` are used on Linux, and
:file:`{HOME}/.matplotlib` on other platforms, if they are
writable. Otherwise, the Python standard library's `tempfile.gettempdir`
is used to find a base directory in which the :file:`matplotlib`
subdirectory is created.
```

## 二次封装
matplotlib作为Python最火爆的画图库,有很多其他的库对它进行了二次封装:

A large number of third party packages extend and build on Matplotlib functionality, including several higher-level plotting interfaces (seaborn, HoloViews, ggplot, ...), and a projection and mapping toolkit (Cartopy).

我用过的例如:[seaborn](https://seaborn.pydata.org/)[plotnine](https://plotnine.readthedocs.io/en/stable/)都是开箱即用的好库。相比matplotlib的默认样式更加美观,但是自由度有所下降。

## 依赖
matplotlib的最新版本是`3.8.3`,有以下依赖:
```toml
dependencies = [
"contourpy >= 1.0.1",
"cycler >= 0.10",
"fonttools >= 4.22.0",
"kiwisolver >= 1.3.1",
"numpy >= 1.23",
"packaging >= 20.0",
"pillow >= 8",
"pyparsing >= 2.3.1",
"python-dateutil >= 2.7",
"importlib-resources >= 3.2.0; python_version < '3.10'",
]
requires-python = ">=3.9"
```
5 changes: 3 additions & 2 deletions docs/Python/ThirdPartyLibrary/matplotlib/plt.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
tags:
- python第三方库
- matplotlib
---

# plt
# plt everything

matplotlib的函数式调用。
5 changes: 3 additions & 2 deletions docs/Python/ThirdPartyLibrary/matplotlib/subplots.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
tags:
- python第三方库
- matplotlib
---

# axes and figure
# Axes and Figure

matplotlib的面向对象式调用。
2 changes: 1 addition & 1 deletion docs/Python/ThirdPartyLibrary/numpy/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ hide:
- toc
---

# numpy
# numpy
1 change: 0 additions & 1 deletion docs/Python/ThirdPartyLibrary/numpy/ndarray.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
tags:
- python第三方库
- numpy
---

Expand Down
1 change: 0 additions & 1 deletion docs/Python/ThirdPartyLibrary/pandas/dataframe.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
tags:
- python第三方库
- pandas
---

Expand Down
6 changes: 6 additions & 0 deletions docs/Python/ThirdPartyLibrary/pytorch/model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
tags:
- pytorch
---

# 训练一个模型
1 change: 0 additions & 1 deletion docs/Python/ThirdPartyLibrary/pytorch/multi_gpu.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
tags:
- python第三方库
- pytorch
---

Expand Down
1 change: 0 additions & 1 deletion docs/Python/ThirdPartyLibrary/pytorch/tensor.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
tags:
- python第三方库
- pytorch
---

Expand Down
8 changes: 0 additions & 8 deletions docs/Statistics/Data_Mining.md

This file was deleted.

8 changes: 0 additions & 8 deletions docs/Statistics/Pattern_Recognition_and_Machine_Learning.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tags:
---

# 数学分析
> MATH120016+MATH120017,数学分析B,张永跃、严金海
全世界大学生多多少少都应该学一点的科目,不等式和极限的艺术。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tags:
---

# 线性代数
> MATH120044,线性代数,吴肖乐
魅力无穷的一门课。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tags:
---

# 运筹学
> MANA130005,运筹学,周蓉
和统计沾边,但本身是其他学科的分支。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ tags:
---

# 概率论与数理统计
> MANA130001,概率论与数理统计,徐勤丰
这算是统计系入门前的一门通识课了,课程内容可大可小,一般理工科专业都会修读。

## 主要内容
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ tags:
---

# 统计软件
> MANA130076,统计软件,沈娟
!!! info "缘分啊"
沈老师居然是我导的夫人,并且我选这门课的那个学期沈老师刚好怀孕。只能说缘妙不可言!!

应用类型的课程,主讲R语言、SAS和Python等应用程序的统计实践。

Expand Down
9 changes: 9 additions & 0 deletions docs/Statistics/elective/Algorithm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
tags:
- 统计选修课
---

# 算法导论
> COMP119004,计算思维,汪卫、黄萱菁
计算机算法入门。
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
tags:
- 统计基础课
- 统计选修课
---

# 统计计算
> MANA130368,统计计算,蒋飞宇
很重要的统计应用课,主讲数值算法、模拟算法。
9 changes: 9 additions & 0 deletions docs/Statistics/elective/DSPython.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
tags:
- 统计选修课
---

# 数据科学编程基础
> MANA130398,数据科学编程基础,孙海
numpy+pandas+matplotlib三剑客。
9 changes: 9 additions & 0 deletions docs/Statistics/elective/Data_Mining.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
tags:
- 统计选修课
---

# 数据挖掘
> MANA130374,数据挖掘原理与技术,王有为
主讲处理大数据的各类算法。
9 changes: 9 additions & 0 deletions docs/Statistics/elective/Database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
tags:
- 统计选修课
---

# 数据库
> MANA130373,数据库与企业数据管理,张成洪
数据库、SQL入门。
9 changes: 9 additions & 0 deletions docs/Statistics/elective/OpenMMLab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
tags:
- 统计选修课
---

# OpenMMLab实践
> 华五AI+X微专业,商汤
深度学习第一课。
Loading

0 comments on commit 53b9eb4

Please sign in to comment.