6 CommentsOldest to Newest
What if there are multiple lines and we want to change the color of only the one we clicked on. Setting buttonDownFcn of each line separately does not sound practical.
If I had multiple lines e.g. h=plot(rand(5,5);
I can set their callback with one command: set(h,’ButtonDownFcn’,@changeColor);
Only the line you click on will change color. Is this what you mean?
Yes. Thank you.
Is it possible to change the color of a line when the mouse cursor hovers on it, without clicking. I could not see a “mouse over” kind of functionality in the documentation.
There is not currently an easy way to do this. You could take a look at this file exchange submission: http://www.mathworks.com/matlabcentral/fileexchange/27632-hover-highlight
Add a breakpoint in your callback routine and take a look at the properties of event_obj. You should be able to get the color of the line either from it or its parent.