Hello, thanks for looking at this,
I'm having trouble keeping track of the current axes in my GUIDE application. What I have is a simple GUIDE application with four axes: when I press on any of the four axes I can use the get(gca) command to find what axes I'm on. My problem comes when I plot anything: whenever I plot anything the gca is never set to whatever I click on anymore. I think it has something to do with clicking on the plot compared to clicking on the axes, hence the current axes handle never changes.
What is strange is if I use the command: get(figure1, 'CurrentAxes') I CAN find the axes I clicked on, but the get(gca) command opens a new figure with a new axes. I have a scroll function callback that uses command:
if get(volprototype, 'CurrentAxes') == handles.axes1
and I can use this to check if the axes does in face correspond to the current axes. My problem is when I execute this code, and do the scroll callback, it exits out if I scroll too quickly. I can scroll slowly and it works perfectly, but if I scroll quickly it creates a error.
So, here are my questions:
Why does it exit out if I scroll too quickly? Is there a better way I can check the current axes? This is causing a few problems for me, and I want to get this scroll function callback working before I continue with the rest of my application.

2 件のコメント

Adam
Adam 2014 年 11 月 19 日
Why do you need to know the current axes? Are you clicking on an axes in the GUI to make it the next axes to plot on?
I almost never use gca for plotting, especially not when using Guide, I just use an explicit plot instruction onto the axes I want using its tag.
Brian
Brian 2014 年 11 月 19 日
Because my windows scroll function has three unique functions for each axes, and while I can not specify any axes and run the scroll callback regardless, I will sometimes get errors because the wrong gca will use the wrong callback.
I use the if statement to verify I'm doing the right thign to the right axes. If this is a dumb way to go about it, I'd love to hear an alternative: I taught myself GUIDE and while I can usually get a few things done well, when I add multiple axes with unique callbacks, etc I find myself getting less and less organized.

サインインしてコメントする。

 採用された回答

Image Analyst
Image Analyst 2014 年 11 月 19 日

0 投票

If clicking on an axes changes the gca, then you're fine. Just don't specify the axes handle in any call to plot() and don't call axes() before any call to plot(). Then it will just use the gca by default.

5 件のコメント

Brian
Brian 2014 年 11 月 19 日
Because my windows scroll function has three unique functions for each axes, and while I can not specify any axes and run the scroll callback regardless, I will sometimes get errors because the wrong gca will use the wrong callback.
What I'm doing is scrolling through a stack of images, and I have three 2D plots (XY,XZ,YZ) using one scroll callback to sift through the volume.
Image Analyst
Image Analyst 2014 年 11 月 19 日
If that's the case then you're stuck using an if test to see which of the known axes matches the handle ID number of the current axes, like you already showed.
Brian
Brian 2014 年 11 月 21 日
Thanks, and sorry for the late reply,
That's what I've been doing over yesterday, and I can find the ID. My problem is if I find the ID using get(figure, 'CurrentAxes') I get a numerical ID, and when I use my callback quickly it causes the GUI to crash.
I can use the callback slowly (one turn every third of a second or so). But when I try to zip through, it causes a crash. I'm guessing I'm scrolling faster than that code executes, or some similar problem.
Any ideas?
Image Analyst
Image Analyst 2014 年 11 月 21 日
Brian
Brian 2014 年 11 月 25 日
Thanks for your help! I will look at this link.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2014 年 11 月 19 日

コメント済み:

2014 年 11 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by