On 2/24/2013 1:28 PM, Paul Anton Letnes wrote:
Hi everyone,
I've been looking into making an animation of a mechanical system. In its
first incarnation, my plan was as follows:
1) Make a fading line plot of two variables (say, x and y)
2) Run a series of such plots through ffmpeg/avencode to generate an animation
First, I'm wondering whether there's a built-in way of making a fading line
plot, i.e. a plot where one end of the line is plotted with high alpha, the
other end with low alpha, and intermediate line segments with linearly scaled
alpha. For now, I've done this by manually chunking the x and y arrays and
plotting each chunk with different alpha. Is there a better way? Is there
interest in creating such a plotting function and adding it to matplotlib?
Second, is there a way of integrating the chunked generation of fading
lines with the animation generating features of matplotlib? It seems
possible, although a bit clunky, at present, but maybe someone has a better
idea at what overall approach to take than I do.
Cheers
Paul
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Paul,
I've had to do something similar to what you need, and I found the
following example from the Gallery quite helpful:
http://matplotlib.org/examples/pylab_examples/multicolored_line.html
I think the second plot in particular is pretty close to what you want;
however, you'll need to set the alpha values manually. This is what I've
done for line collections, scatter plots, etc.
_
import numpy as np
import matplotlib.pyplot as plt
norm_data = np.random.rand(20)
xs = np.random.rand(20)
# Pick a colormap and generate the color array for your data
cmap = plt.cm.spectral
colors = cmap(norm_data)
# Reset the alpha data using your desired values
colors[:,3] = norm_data
# Adding a colorbar is a bit of a pain here, need to use a mappable
fig = plt.figure()
plt.scatter(xs, norm_data, c=colors, s=55)
mappable = plt.cm.ScalarMappable(cmap=cmap)
mappable.set_array(norm_data)
fig.colorbar(mappable)
plt.show()
_
Hope that helps a little.
Ryan
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users