小编典典
假设有一个散点图scat = ax.scatter(…),则可以
改变立场
scat.set_offsets(array)
其中array是N x 2x和y坐标的形状数组。
改变大小
scat.set_sizes(array)
其中array是以点为单位的一维尺寸数组。
改变颜色
scat.set_array(array)
其中array是一维值数组,将对其进行颜色映射。
这是一个使用animation模块的简单示例。
它比必须的要复杂一些,但是这应该为您提供一个做奇特的事情的框架。
(代码编辑于2019年4月以与当前版本兼容。有关旧代码,请参阅修订历史记录)
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
class AnimatedScatter(object):
“”“An animated scatter plot using matplotlib.animations.FuncAnimation.”“”
def init(self, numpoints=50):
self.numpoints = numpoints
self.stream = self.data_stream()
# Setup the figure and axes...
self.fig, self.ax = plt.subplots()
# Then setup FuncAnimation.
self.ani = animation.FuncAnimation(self.fig, self.update, int