Hi all,
I'm trying to animate scatter plots on Matplotlib 1.2.1.
My code is as below:
> import numpy as np
> import matplotlib as mpl
> import matplotlib.pyplot as plt
> import matplotlib.animation as anm
>
> x = np.array([np.cos(i) for i in np.arange(0.0, 360.0, 9.0) / 180.0 * np.pi])
> y = np.array([np.sin(i) for i in np.arange(0.0, 360.0, 9.0) / 180.0 * np.pi])
> z = np.arange(0.0, 1.0, 0.025)
>
> cdict = {
> 'red': (
> (0.0, 0.0, 0.0),
> (0.5, 0.5, 0.5),
> (1.0, 1.0, 1.0)
> ),
> 'green': (
> (0.0, 0.0, 0.0),
> (0.5, 0.0, 0.0),
> (1.0, 0.0, 0.0)
> ),
> 'blue': (
> (0.0, 0.0, 0.0),
> (0.5, 0.0, 0.0),
> (1.0, 0.0, 0.0)
> )
> }
> my_cmap = mpl.colors.LinearSegmentedColormap('my_colormap', cdict, 256)
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
>
> def init():
> sct.set_offsets(([], []))
>
> def update_sct(i, sct):
> sct.set_offsets((x[i], y[i]))
> return sct
>
> sct = ax.scatter([], [], marker = 'o', s = 10.0, linewidth = 1.0, cmap =
> my_cmap, c = [])
> sct_anm = anm.FuncAnimation(fig, update_sct, fargs = (sct,), interval = 100,
> frames = len(x))
> ax.set_xlim((-2.0, 2.0))
> ax.set_ylim((-2.0, 2.0))
> plt.show()
Now I'm trying to set scatters' colors mapped by 'z'.
How can I set scatters' c values in each frame?
Magician
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users