make axes bigger when mouse clicked

1 view (last 30 days)
best16 programmer
best16 programmer on 25 Apr 2017
Commented: AstroGuy1984 on 25 Apr 2017
hi matlab community,i am a begginer in matlab gui, i have 7 axes in my gui i don't know if it's possible that when I click or pass the mouse on one of the axes it will be shown bigger in the middle of the gui. thanks for advance

Answers (1)

AstroGuy1984
AstroGuy1984 on 25 Apr 2017
When you say "7 axes" are you meaning 7 separate axes objects or 7 series within a singular axes object? I am assuming you mean 7 separate plots and you want to be able to "blow up" a clicked plot into the main plot.
Nonetheless, I believe where you will want to start with is the ButtonDownFcn property within the Axes object in question. So when you instantiate your axes object, set the property there as such:
axes('Parent', fig_handle, ..., 'ButtonDownFcn', @function_name);
where ... are all the other properties for your axis when you create it. If you are using GUIDE, you can just set that one property in the normal way using:
set(axes_handle, 'ButtonDownFcn', @function_name);
From there you will want to make a callback function (name it whatever you are setting the ButtonDownFcn to be) and give it similar arguments to what you'd get in a regular callback:
function function_name(hObject, event)
% CODE
end
hObject will be the Axes object clicked and the event object will contain a property to tell you where it was hit. From there, you now know what plot was clicked for copying into a larger plot.
It's hard to tell you where to go from there without knowing about the destination, but I'd heavily suggest using the copyobj() function for copying series within a plot.
  4 Comments
AstroGuy1984
AstroGuy1984 on 25 Apr 2017
I am only able to provide a guess like I did above (looping into the children of the source axes and copying them into the destination axes). Likewise, you can copy over any other properties you wish to.
Do you have the destination axes drawn or do you wish for it to appear upon click? You are going to want to reference that axes as the destination object like in the loop above.
If you used that loop inside the axesClicked_Callback() function above, that will be a good start, and hopefully get you in a position where you can figure out what other things you want to copy. You're going to need the destination axes handle if it already exists, and you'll need to make one if you're drawing the new plot within the function.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!