matplotlib可视化_matplotlib中的动画可视化

matplotlib可视化

Data analysis is about telling a story. Whether it’s a story about your customers, the services you provide or maybe even macroeconomic development, your goal as a data scientist is to deliver a message that compels, persuades, and convinces your audience to take action.

数据分析是讲故事。 无论是有关客户,提供服务或什至是宏观经济发展的故事,您作为数据科学家的目标都是传递可迫使,说服并说服听众采取行动的信息。

But power of the story depends on how well it is performed.

但是故事的力量取决于它的表现。

If you have a great story, but deliver it poorly, your audience is less likely to take action. That’s where animated presentation can help.

如果您有一个很棒的故事,但表现不佳,那么您的听众就不太可能采取行动。 这就是动画演示可以提供帮助的地方。

Animated Visualization is a rich, engaging medium, easy to manage, and will help your key points pop. It offers all the benefits of a visual medium with much smaller resource requirements than you might expect.

动画可视化是一种丰富,引人入胜的媒体,易于管理,并且可以帮助您突出关键点。 它提供视觉媒体的所有优势,而资源需求却比您预期的要少得多。

I would like to show how in a few steps you can create animation in Matplotlib.

我想展示一下如何在Matplotlib中创建动画。

# STEP 1: Import the necessary modulesimport numpy as np
import pandas as pd
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
plt.style.use('seaborn-pastel')# STEP 2: Set up the plotting areafig = plt.figure(figsize=(9,7));
ax = plt.axes(xlim=(0, 4), ylim=(-2, 2));# STEP 3: Create data to plotline, = ax.plot([], [], lw=3);def init():
line.set_data([], [])
return line,# STEP 4: create a function to update the linedef animate(i):
x = np.linspace(0, 4, 1000)
y = np.sin(2 * np.pi * (x - 0.01 * i))
line.set_data(x, y)
return line,# STEP 5: call FuncAnimation and showanim = FuncAnimation(fig, animate, init_func=init,
frames=200, interval=20, blit=True);
anim.save('sine_wave.gif', writer='imagemagick');

Animated sinusoid

动画正弦曲线

Animated Visualization of Time Series (1-minute Gold Price for 2018 yr.)

时间序列的动画可视化(2018年1分钟金价)

Image for post

The Bayes update

贝叶斯更新

This animation displays the posterior estimate updates as it is refitted when new data arrives. The vertical line represents the theoretical value to which the plotted distribution should converge.

当新数据到达时,该动画将显示后验估计更新,并进行更新。 垂直线表示绘制的分布应收敛的理论值。

Image for post

Animated histogram

动画直方图

This example shows how to use a path patch to draw a bunch of rectangles for an animated histogram.

本示例说明如何使用路径补丁为动画直方图绘制一堆矩形。

Image for post

An animation of random data

随机数据的动画

Image for post

Rain simulation

降雨模拟

Simulates rain drops on a surface by animating the scale and opacity of 50 scatter points. (Author: Nicolas P. Rougier)

通过设置50个散射点的比例和不透明度动画来模拟表面上的雨滴。 (作者:Nicolas P. Rougier)

Image for post

翻译自: https://medium.com/@wetpaint3/animated-visualization-in-matplotlib-60cd9649f8f9

matplotlib可视化

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值