How to click the subplots
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to get the indexces of the subplot if clicked by mouse. For example, I have 10 figures shown by subplot.
for i=1:10
subplot(1,5,i), imshow(img{i});
end
Now if user click image 5, and 8 then somehow I should get variable name C with values 5 and 8.
0 commentaires
Réponses (2)
Jan
le 8 Jan 2017
Modifié(e) : Jan
le 8 Jan 2017
function FigH = main
FigH = figure('UserData', []);
for i = 1:10
subplot(1, 10, i); % You need 10 SUBPLOTs for 10 images
image(rand(100,100,3), 'ButtonDownFcn', {@Callback, i}); % Not IMSHOW
end
function Callback(ObjectH, EventData, Index)
FigH = ancestor(ObjectH, 'figure');
disp(Index)
UserData = [get(FigH, 'UserData'), Index];
set(FigH, 'Userdata', UserData);
Now you can call this from e.g. the command line:
FigH = main;
Then click on the images as wanted. Finally you can request:
C = get(FigH, 'UserData')
0 commentaires
Ling Mei
le 6 Mai 2019
the simplest way is just add 'axcopy' to the end of the figure,
such as:
figure();
for i=1:4
subplot(2,2,i);
plot(1:10,rand(1,10)*100,'k','linew',2);
end
axcopy;
You would have a pop-out subplot if you click the area of subplotted figure.
1 commentaire
Walter Roberson
le 6 Mai 2019
axcopy appears to be a ucsd function such as http://www.indiana.edu/~pcl/busey/temp/eeglabtutorial4.301/allfunctions/axcopy.m and appears to be included in eeglab
I also find a modified version in erplab
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!