On Mon, Jan 23, 2012 at 3:19 PM, Paul Ivanov <pivanov...@gmail.com> wrote:
> Paul Ivanov, on 2012-01-23 13:07, wrote:
> > the quick and dirty way to get close to what you want is to add
> > an alpha value to the lines you're already plotting. Here's a
> > small example:
> >
> > x = np.arange(0,3,.01)
> > y = np.sin(x**2)
> > all_x,all_y = [],[]
> > ax = plt.gca()
> > for i in range(100):
> > noisex = np.random.randn(1)*.04
> > noisey = (np.random.randn(x.shape[0])*.2)**3
> > ax.plot(x+noisex,y+noisey, color='b', alpha=.01)
> > all_x.append(x+noisex)
> > all_y.append(y+noisey)
> >
> > To get a heat diagram, as was suggested, you can use a 2d
> > histogram.
> >
> > plt.figure()
> > all_x =np.array(all_x)
> > all_y = np.array(all_y)
> > all_x.shape = all_y.shape = -1
> > H, yedges, xedges = np.histogram2d(all_y, all_x, bins=100)
> > extent = [xedges[0], xedges[-1], yedges[-1], yedges[0]]
> > ax = plt.gca()
> > plt.hot()
> > ax.imshow(H, extent=extent, interpolation='nearest')
> > ax.invert_yaxis()
>
> For completeness, attached is what the hexbin version of the same
> data looks like:
>
> plt.hexbin(all_x, all_y)
>
> You may want to play with the 'bins' (for histogram2d) and
> 'griddata' (for hexbin) parameters to get the appropriate level
> of detail for the amount of data you have.
>
>
To get a proper count of the 2D bins that each curve crosses, you could
parameterize the curve by arclength and resample it use a small step size.
Or, you could linearly interpolate between the curve's discretized data
points using Bresenham's line algorithm. The latter seemed like a
straightforward approach, so I wrote it up and added it to the SciPy
Cookbook:
http://www.scipy.org/Cookbook/EyeDiagram
Warren
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users