Changing axes properties with the mouse
Today we’re going to learn how to change some axes properties with the mouse.
First, start a new m file function that will contain our work.
Create the axes on which our work will be based on. Give the axes a handle (h) so we can change and obtain (set and get) its properties later.
You’ll see that the handle variable h has an orange (warning) underline. This happens when your function contains an unused variable in it. We will use this handle soon in manipulating the axes.
To see the newly created axes, run the function.
The first thing we will do with our axes is getting mouse click input. To do this, we first assign a buttondownfcn to our axes.
Now whenever we click on the axes with the mouse, we go to the function press1 and perform whatever is instructed there.
We will at first put an acknowledgement of the mouse click. This is done by changing the title of the axes whenever we click on it with a small phrase. This phrase then disappears after half a second.
Try it!
Next we will identify the coordinates of the mouse click. To do this, first delete the previous lines inside the press1 function. To get the mouse click coordinates, we will make use of an axes property called currentpoint.
So we take the currentpoint value in our axes and store the result in a variable, as follows.
Of this new variable (which will be a 2 by 3 matrix), we are interested in the x and y coordinates, namely elements (1,1) and (1,2) of the matrix p.
Now we have the x and y coordinates of the mouse click(s) stored in appropriate variable names. To show these values, we will change the title of the axes accordingly, as done before.
The x and y variables are numeric, while the title of the axes contains string values. For this reason, we will convert the numeric data into string data, and then put it as a title for the axes. For aesthetic reasons, we will also put a comma between the two values. This is shown in the following code snippet.
Result:
We can do more things with the mouse click coordinates. For example, the following code plots a star wherever you click the mouse on the axes. Since in MATLAB plotting a new plot replaces the old one, we will use the command hold on to make sure each star plotted stays on the axes.
Also, we set the axes limits beforehand so they stay the same and don’t change after every star plotted.
Result:
For our final example, we want to change the axes axis limits with mouse clicks. That is, when we click on the far right of the axes, the x-limit changes accordingly. The algorithm works as follows:
- Get x and y coordinates for mouse click.
- If x coordinate is in last 0.05 of the x-limit, shift x-limit right.
- Similarly, if x coordinate is in first 0.05 of the x-limit, shift x-limit left.
- Do the same for the axes y-limit.
The following is the code with comments.
Thanks for tuning in J
Popularity: 3% [?]
Binary Dilation and Erosion
Popularity: 4% [?]
ROC curve
ROC – Receiver Operating Characteristics.
The ROC graphs are a useful technique for organizing classifiers and visualizing their performance. ROC graphs are commonly used in medical decision making.
The function computes and plots the classical ROC curve and the mirrored ROC curve (in my opinion, it is more useful).

An example of roc.m output plot
The input is a Nx2 matrix: in the first column you must insert the test value and in the second you must insert 1 if the subject is a patient or 0 if he is healthy (or, more general, use 1 and 0 to discriminate the subsets of subjects).
I.E. X=[165 1; 140 1; .... 166 0; 176 0] (load rocdata) then call roc(X).
The function will return a table
ROC CURVE DATA
——————————————–
Cut-off point Sensitivity Specificity
…
131.0000 0.2414 0.9762
132.0000 0.2586 0.9762
…
151.0000 0.7500 0.8095
152.0000 0.8017 0.8095
…
218.0000 1.0000 0.0476
239.0000 1.0000 0.0238
——————————————————————————–
and the statistic results:
ROC CURVE ANALYSIS
——————————————————————————–
AUC S.E. 95% C.I. Comment
——————————————————————————–
0.87541 0.02713 0.82224 0.92858 Good test
——————————————————————————–
Standardized AUC 1-tail p-value
13.8375 0.000000 The area is statistically greater than 0.5
Cut-off point for best Sensitivity and Specificity (blu circle in plot)= 152.0000
In the ROC plot, the cut-off point is the closest to [0,1] point or, if you want, the closest to the green line
where AUC is Area under the curve and S.E. is Standard Error
If you have downloaded partest (http://www.advancedmcode.org/partest.html) the routine will compute several data on test performance.
If any problems occurs in execution, or if you found a bug, have a suggestion or question just contact me at:
giuseppe dot cardillo-edta at poste dot it
You can visit my homepage http://home.tele2.it/cardillo
My profile on XING http://www.xing.com/go/invita/13675097
My profile on LinkedIN http://it.linkedin.com/in/giuseppecardillo
Download Now
Popularity: 5% [?]





























































