# How can the data cursor tool display the points from the curve on the axes on the left side of the plot generated by PLOTYY?

8 views (last 30 days)
Following the example in the MATLAB documentation for PLOTYY, I have created a plot using the following code:
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
[AX,H1,H2] = plotyy(x,y1,x,y2,'plot');
When I enable the Data Cursor tool, I cannot get MATLAB to display the [X,Y] values of the curve on the left side axes of the plot. I would like to be able to select the points on the curve from the left-hand axis, not the right-hand axis.

MathWorks Support Team on 27 Jun 2009
This enhancement has been incorporated in Release 2008a (R2008a). For previous product releases, read below for any possible workarounds:
The default behavior of the Data Cursor tool selects the axis on the right, since it is the 'CurrentAxes' (the one most recently drawn by the PLOTYY function. To get the data cursor to pick points from the curve on the left-hand axis, you can execute the following series of commands after the figure is plotted:
set(gcf,'currentaxes',AX(1)) % Make the axes on the left the current axes
set(AX(2),'hittest','off') % turn off the HitTest property on the axis on the right
set(AX(1),'hittest','on') % Turn on HitTest for the appropriate axis
Now the data cursor will only pick points on the curve from the axis on the left side of the plot. To switch back, execute the following code:
set(gcf,'currentaxes',AX(2)) % Make the axes on the left the current axes
set(AX(1),'hittest','off') % turn off the HitTestproperty on the axis on the right
set(AX(2),'hittest','on') % Turn on HitTest for the appropriate axis

### Tags

No tags entered yet.

R14SP1

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!