From: Dave on
I am using patch to generate many polygons with different colors, where each color represents a value.

I would like to be able to click on a polygon and print what that value is in the command window. I'm attempting to do this by writing a callback for ButtonDownFcn.

The patch command, however, generates a single object so it can have only a single callback for ButtonDownFcn. As far as I can tell, that callback does not provide any information about what face was clicked.

Is there any way to:
1. figure out which face was clicked;
2. provide a different callback for each face; or
3. provide a different callback argument for each face?

I know that I could generate a separate patch object for each polygon, however, I am generating tens of thousands of these so I'm concerned that there would be a performance issue. I'm about to try it anyway though with the profiler.

Any help will be appreciated, thanks
From: Walter Roberson on
Dave wrote:
> I am using patch to generate many polygons with different colors, where
> each color represents a value.
>
> I would like to be able to click on a polygon and print what that value
> is in the command window. I'm attempting to do this by writing a
> callback for ButtonDownFcn.

Perhaps you should be using datacursormode() instead?