how to create new figure with same image when you click on image in axes
1 次查看(过去 30 天)
显示 更早的评论
i have a multiple set output images which are to be shown in axes of my gui. now when i click on any one image i want that image to show in a separate figure window.
0 个评论
回答(1 个)
Walter Roberson
2014-4-21
set the callback for the image() object to something like,
function show_in_figure(hObject, event)
hfig = figure();
hax = axes('Parent', hfig);
copyobj(hObject, hax);
axes(hax, 'image');
end
3 个评论
Walter Roberson
2014-4-21
image(DataMatrixForThisImage, 'Callback', @show_in_figure);
The show_in_figure function could go in a separate .m file -- that is what I would suggest if you are using GUIDE, so that GUIDE does not accidentally overwrite the code when it rebuilds the .m
You can use exactly the same callback for multiple images. The hObject value that MATLAB passes to the callback will be the handle of the image that got clicked on.
Note: you might want to record the output of copyobj() and use it to set() the Position of the image within the axes -- you might also want to set() the Position and visibility of the new axes (which can, in this code, be referenced by hax )
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!