Passing 'figure_handle' to 'datacusormode' in user-created class.

3 次查看(过去 30 天)
I have a custom-class that I am using with a GUIDE-generated GUI. I want to create custom data-cursors. However, when I try to pass the axes-object to 'datacursormode(figure_handle)', I get the error 'Invalid figure handle'. My constructor is attached below. Any help is appreciated.
% Constructor
function obj = annotatorGUIClass(rawAxes, psdAxes, allAxes, parentFigure)
obj.rawDataDisplayAxes = rawAxes;
obj.psdDataDisplayAxes = psdAxes;
obj.allPairDisplayAxes = allAxes;
obj.dcmRaw = datacursormode(rawAxes);
obj.dcmPSD = datacursormode(psdAxes);
obj.rawDataDisplayAxes.NextPlot = 'replacechildren';
obj.psdDataDisplayAxes.NextPlot = 'replacechildren';
obj.allPairDisplayAxes.NextPlot = 'replacechildren';
obj.viewMode = 'Raw';
parentFigure.Renderer = 'painters';
end

采纳的回答

Steven Lord
Steven Lord 2015-7-27
DATACURSORMODE accepts a figure handle, not an axes handle.
If you want to change the behavior/format based on the axes containing the object on which you clicked, I would use ANCESTOR in the UpdateFcn to find the axes containing the object whose handle is the UpdateFcn's Target input argument and use that to determine which behavior/format to use.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by