Moving curves

This lab is a simplified version of a real application I made. A graduate student in physics needed a simple way to compare data from experiments.
Each set of data consists of points along different curves. After having plotted the curves, one can, using the mouse, drag a curve to another location in the plot. This makes it possible to put curves close to each other in order to compare them (to compare the shape of peaks, for example).

Your program should be able to do at least the following (you can make a fancy GUI if you like): Hints: the following properties can be useful: the CurrentPoint-property of the current axis, the Pointer-property of the current figure.
axis manual 

Here is some test-data for two curves (x1, y1) and (x2, y2) (your program should work any number of curves and for any x, and y, with positive elements, however):

x1 = logspace(-5, 5, 60);
y1 = 5 * exp(2 * sin(log(x1)));
x2 = logspace(-4, 4, 30);
y2 = 1e-2 * (x2 + 1 ./ x2);

Here are two small images. The left shows the original position of the curves and in the right the curves have been moved.

original after movement

November 21, 2012:
One student noticed that the WindowButtonMotionFcn does not behave properly. It says in the documentation that:
Mouse motion callback function. Executes whenever you move the pointer within the figure window.

As it turns out, the callback executes outside the window provided you hold down a mouse button.

So, if a user of your program should not be able to move the curve (completely) outside the axis-limits you can compare the currentpoint data with the axis and not move the curve too far.

Back