Maximum Number of UIAxes in App Designer 2017b

Hi!
I recently have been tasked with building a large GUI in Matlab App Designer. After finally finishing placing all the UI elements, I notice that my plotting functions no longer work when calling them. The figures that these plotting functions relate to are also not visible, but still contained in the GUI object. There are no errors reported for this, but rather the GUI refuses to update those plots. The rest of the data is visible on other tabs and the GUI is still functional.
After a bit of searching on other issues related to this, I found this post: https://www.mathworks.com/matlabcentral/answers/327311-why-do-app-designer-uiaxes-elements-start-to-disappear?s_tid=answers_rc1-2_p2_MLT which mentions a limit of 16 axes that was supposed to be fixed for 2017a. The GUI has well over 100 UIAxes in the app currently, so I'm wondering if there is a new limit within MATLAB.
Thanks!
EDIT: I have attached an error that showed up probably 20 minutes after clicking the plot menu action.

2 Comments

What kind of graphics card does your machine have? (Some cards have an inherent limit on the nuber of graphics contexts that can be created.) You can query this by:
>> opengl info
Hi Chris,
Thank you for the suggestion. I have attached the output here:
opengl_info.png

Sign in to comment.

Answers (1)

MATLAB got past the old limit (which was imposed by the technology used) by falling back to a different way to create graphics contexts. However, some graphics cards have limits on how many graphics contexts they can make. You may be running into a limit from that. The error log you attached (thanks!) shows the problem was in the fallback graphics creation.
You may be able to avoid the first limit (and thus avoid the fallback which may be hitting the other limit) by putting your UIAxes into different uifigures. Can you group them into different figures?
How many UIAxes are you getting successfully? Or if they don't work, do all stop working?
I'm also interested in the info Chris requested above.
thanks
andy

7 Comments

Sorry, I mean to make that a comment on the question rather than an answer, at least until we helped you get past the problem.
andy
Hi Andy,
Thanks for the suggestion here. In the past I was able to get 16 to show at 1 time. It seems now that I can have 16 available, but in different tabs. Here is a shot of 12 showing in 1 tab. When I click the other Rx Combined tab I see 4 more. 12_axes.png
This is the view on the other tab. Theother Rx Spectrum and Rx Phase tabs have the same non-filled boxes as in the figure above (where there should be an axes object).
4_combined_axes.png
As per your suggestion on grouping them into other figures, I was hoping to have elements of the GUI within tabs as highlighted above. Is there an option for MATLAB app designer to load another figure with these plots in that figure? This way I could avoid having to programmatically generate the figures.
Your graphics driver is a little old. I don't know if there is a specific problem with it, but maybe updating would help.
It should be that after your first 16, you should still be able to make more axes but they will be generated in a different way. (You shouldn't be able to tell the difference usually.) If you aren't getting more than 16 at all, I'd try updating the driver, and then contacting support.
Are you able to make regular figures with graphics on the same system? In other words, can you do plot(peaks) (for example) in MATLAB and see the picture?
As far as creating multiple figures, I see this:
I'm more of a graphics guy than an app designer guy, so am not sure, and I think that looks a bit more involved than what you'd want.
In R2018b, you can put subplot in an app designer figure if you turn off AutoResizeChildren. Multiple axes in a subplot all use a single graphics context.
f = app.UIFigure;
f.AutoResizeChildren = 'off';
a = subplot(2,2,1, 'Parent', f);
plot(a,peaks)
a = subplot(2,2,2, 'Parent', f);
plot(a, magic(5))
a = subplot(2,2,3, 'Parent', f);
plot(a, 1:10)
a = subplot(2,2,4, 'Parent', f);
plot(a, rand(1,20))
Does that help?
andy
Hi Andy,
I went through the process of updating graphics drivers for my laptop. This seemed to help a bit as now I can get around 36 axes to show at a particular moment in time. While this is more than I would ever have visible within a tab at one time, there seems to be some additional rendering issues.
Between the several tabs and axes, I tend to get the first 18 or 20 axes to show up in the GUI, then MATLAB skips showing all the remaining axes (probably between 60 and 80) until it gets to the last tab and shows the last 16 plots (on that last tab). To see if I could change this behavior I set the other unused axes to have their Visible property set to "off." (This was to test if I perhaps I could have MATLAB only render the visible axes). However this did not change the number of plots I could render.
I could see a work around if there was a way to tall MATLAB to only render the visible axes on the current tab, rather than trying to have all the other axes sitting in graphics memory. Something like: user clicks on tab, MATLAB reners only the axes in current tab. User clicks new tab, MATLAB disables rendering of previous tab axes and only renders current tab. Is anything like this possible in MATLAB?
The specific behavior is that when you go over the limit of graphics contexts, it removes the oldest of the contexts. That's why you are seeing the 16 final views. I think your card seems to be having a limit on graphics contexts, and maybe it is showing 18 or 20 before it gives up.
How many separate regular figures can you make?
for i = 1:n
f = figure; axes(f)
end
Can you do the above (from MATLAB command window, not app) with n = 30?
The behavior of an axes for Visible = 'off' is to make the axes decorations themselves (axles, ticks, labels) invisible. The contents remain visible. I was going to look up whether the tabs have a visible property, but I'm not sure how that would interact with the behavior of tabs, showing one at a time. Seems like it ought to do the trick.
Thanks for updating your driver, and I'm glad it helped a bit. I suggest you contact support and tell them about this page, and how many figures you can make at once (like the loop I show above). I am not positive we'll be able to solve it, but I at least want to see if there is a difference between how many axes you can show in an app vs how many you can draw normally.
andy
Hi Andy!
Thank you for the suggestions here. I ran the snippet of code above in MATLAB and was easily able to draw 30 figures. I was even able to draw around 96 of 100 figures using the same loop including a plot command for each figure. It seems that there is a limit to the number of figures I can draw between 100 and 160 because MATLAB runs out of graphics memory around 160 figures and starts throwing GC limit exceptions. I'll contact support and see if I can work through something with them. Thank you again for your help and suggestions with this issue!
Commenting here to list two possible work arounds. The total number of possible axes is split between the custom GUI and App Designer. If App Designer is closed and the GUI is run separately, this can allow a few more axes to show up. Another possible work around is to consolidate figures and plot multiple datasets on the same plot. This was the trick used in this case to cut down on the number of figures from around 200 to ultimately get the number of figures down below 100. This limit is based on the particular graphics card of the PC. For the best performance it seems that a limit of less than 100 figures contained in a single .mlapp file works well even on simple Intel Graphics as shown above. If more figures are needed, then a separate GUI can be created and data could be shared between the two as described in this article: https://www.mathworks.com/help/matlab/creating_guis/creating-multiwindow-apps-in-app-designer.html. Thanks to Chris and Andy and the MathWorks support team for helping out here!

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Release

R2017b

Asked:

on 4 Dec 2018

Commented:

on 18 Dec 2018

Community Treasure Hunt

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

Start Hunting!