user2724407
user2724407

Reputation: 99

detect clicked line in an axes in matlab

I've an axes with multiple plot . I would like to know if there is a way to detect which plot I've cliked using datacursor mode. I've already a callback that give the value I've cliked.

Upvotes: 3

Views: 284

Answers (1)

marsei
marsei

Reputation: 7751

As documented in matlab, datacursormode can output the handle of the target line (or any graphical object) your cursor is on. The property Target in the following code is used to make the plot thicker.

dcm_obj = datacursormode(fig);         %enable data cursor mode
cursor_info = getCursorInfo(dcm_obj);  %get the properties
set(cursor_info.Target,'LineWidth',2)  %the target handle is Target

Upvotes: 3

Related Questions