最被低估的Python绘图库,Matlplotlib 超强实力鉴赏

最被低估的Python绘图库!Matlplotlib 超强实力鉴赏

![](https://my-wechat.oss-cn-beijing.aliyuncs.com/text-shadow_20211216170704.png)
## Matplotlib
> Matplotlib 是一个 Python 的 2D绘图库,它以各种硬拷贝格式和跨平台的交互式环境生成出版质量级别的图形。

Python宇宙的绘图库层出不穷,比如boken seaborn pyechart altair plotly pygal ggplot等等。这些库各有优势,很多也是基于Matplotlib的,用起来确实极端代码实现很酷的图表,但是也会失去一些主动性和乐趣。

今天向大家推荐一个开源项目,包括PDF书,完整代码,各种已实现图表。

https://github.com/rougier/scientific-visualization-book/

## 比如这个sin-cos动图的实现
![](https://my-wechat.oss-cn-beijing.aliyuncs.com/downloaded-GIF%20(2)_20211216173112.gif)
```
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig = plt.figure(figsize=(7, 2))
ax = plt.subplot()

X = np.linspace(-np.pi, np.pi, 256, endpoint=True)
C, S = np.cos(X), np.sin(X)
(line1,) = ax.plot(X, C, marker="o", markevery=[-1], markeredgecolor="white")
(line2,) = ax.plot(X, S, marker="o", markevery=[-1], markeredgecolor="white")
text = ax.text(0.01, 0.95, "Test", ha="left", va="top", transform=ax.transAxes)
ax.set_xticks([])
ax.set_yticks([])


def update(frame):
    line1.set_data(X[:frame], C[:frame])
    line2.set_data(X[:frame], S[:frame])
    text.set_text("Frame %d" % frame)
    if frame in [1, 32, 128, 255]:
        plt.savefig("../../figures/animation/sine-cosine-frame-%03d.pdf" % frame)
    return line1, line2, text


plt.tight_layout()
writer = animation.FFMpegWriter(fps=30)
anim = animation.FuncAnimation(fig, update, interval=10, frames=len(X))
from tqdm.autonotebook import tqdm

bar = tqdm(total=len(X))
anim.save(
    "../../figures/animation/sine-cosine.mp4",
    writer=writer,
    dpi=100,
    progress_callback=lambda i, n: bar.update(1),
)
bar.close()
```
## 更多漂亮的案例


![](https://my-wechat.oss-cn-beijing.aliyuncs.com/downloaded-GIF%20(1)_20211216173112.gif)

![](https://my-wechat.oss-cn-beijing.aliyuncs.com/downloaded-GIF_20211216173112.gif)


![](https://my-wechat.oss-cn-beijing.aliyuncs.com/Figure_1_20211216174857.png)

![](https://my-wechat.oss-cn-beijing.aliyuncs.com/polar-projection_20211216174857.png)
![](https://my-wechat.oss-cn-beijing.aliyuncs.com/text-polar_20211216174857.png)

![](https://my-wechat.oss-cn-beijing.aliyuncs.com/spiral-pi_20211216174857.png)
![](https://my-wechat.oss-cn-beijing.aliyuncs.com/windmap_20211216174858.png)

## 最后送大家5张matplotlib必备速查表

![](https://my-wechat.oss-cn-beijing.aliyuncs.com/68747470733a2f2f6d6174706c6f746c69622e6f72672f63686561747368656574732f68616e646f75742d696e7465726d6564696174652e706e67_20211216174814.png)
![](https://my-wechat.oss-cn-beijing.aliyuncs.com/68747470733a2f2f6d6174706c6f746c69622e6f72672f63686561747368656574732f68616e646f75742d626567696e6e65722e706e67_20211216174814.png)
![](https://my-wechat.oss-cn-beijing.aliyuncs.com/68747470733a2f2f6d6174706c6f746c69622e6f72672f63686561747368656574732f68616e646f75742d746970732e706e67_20211216174814.png)
![](https://my-wechat.oss-cn-beijing.aliyuncs.com/68747470733a2f2f6d6174706c6f746c69622e6f72672f63686561747368656574732f63686561747368656574732d312e706e67_20211216174814.png)
![](https://my-wechat.oss-cn-beijing.aliyuncs.com/68747470733a2f2f6d6174706c6f746c69622e6f72672f63686561747368656574732f63686561747368656574732d322e706e67_20211216174814.png)

pdf书/代码/高清速查表已打包,公众号后台回复【速查表】获取
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值