MATLAB Answers

colorbar no longer supported in GUIDE 2020a - quick fix?

92 views (last 30 days)
Sean Tosin
Sean Tosin on 25 Sep 2020 at 14:13
Answered: Sean Tosin on 29 Sep 2020 at 18:45
I'm getting the following message when I open my .fig file in GUIDE (Matlab 2020a, Windows 10):
What's strange is that I wasn't receiving this error before in 2020a so I'm not sure what changed.
I understand GUIDE will no longer be supported but is there an equivalent object or configuration for colorbar I can use to prevent this error for now?
I can't make any changes to the file/GUI as a result so I'm stuck with the current configuration of the .fig file for my app.
When I do make a change and save the .fig and run the associated .m file, I get the following error:
Reference to non-existent field 'axes1'.
handles.axes1 being what I was using as the colorbar reference.


Show 7 older comments
Sean Tosin
Sean Tosin on 28 Sep 2020 at 18:50
When I open the .fig in GUIDE, there is no colorbar present (in the figure) nor is it being controlled separately as a kind of widget control. It seems to be associated with the handles.axes1 however based on the error I get.
handles.axes1 is manipulated and called throughout the code to configure the plot in the GUI and get infromation about it (i.e. set(handles.axes1, 'Visible', 'on'); ColorMap = get(handles.axes1,'CLim'); ZColorMap = get(handles.axes1,'ZLim'); set(handles.axes1,'DataAspectRatio',DA); )
colorbar is only called in the code (.m file) once a plot is generated onto the grid/axes associated with handles.axes1. Here is an example from the code on where this occurs:
scatter3(X, Y, Res*1000, dotsize, Res*1000, '.');colormap('jet');
colorbar, xlabel('X (mm)'); ylabel('Y (mm)'); zlabel('Z (um)'); set(gca, 'Ydir', 'reverse');
xlim([min(X), max(X)]); ylim([min(Y), max(Y)]); axis square; view(0, 90);
ColorMap_Res = get(handles.axes1,'CLim');
handles.ColorMap_Res = ColorMap_Res;
ZColorMap_Res = get(handles.axes1,'ZLim');
handles.ZColorMap_Res = ZColorMap_Res;
Adam Danz
Adam Danz on 28 Sep 2020 at 19:40
I've added that code (and some random numbers to defining missing vars) to a GUIDE gui opening function in r2020b. It creates the colorbar and it's displayed as expected. I opened the fig in GUIDE after doing this and everyting was OK. I opened the fig in GUIDE while the gui function was paused in debug mode and still, no problem.
Is it correct that this warning dialog appears only when you open the GUIDE figure in GUIDE and it appears every time, even if it's the first thing you do after restarting Matlab?
Steven Lord asked an important question to which we do not have an answer. What version of Matlab was this GUI written in?
Sean Tosin
Sean Tosin on 28 Sep 2020 at 19:53
Yes, this dialogue only appears when I open the .fig file in GUIDE (i.e. right clicking on the file in Matlab environment and selecting Open In GUIDE) and appears every time, even if it's the first thing I do after restarting Matlab. If I just open the file (either by double clicking or right click then choose Open), this dialogue does not appear.
If I open the .fig in GUIDE and see this error and make even minor change to the GUI (i.e. move a text box) and save the .fig file and run the corresponding .m file, I get the "Reference to non-existent field 'axes1'" error.
Unfortunately, I inherited this code so it's been difficult to find the exact version this GUI was written, but I mentioned in a previous comment that it's very likely that the earliest version of Matlab used to write the GUI was 2019a

Sign in to comment.

Accepted Answer

Sean Tosin
Sean Tosin on 29 Sep 2020 at 18:45
The issue was that the Tag for the object that I was using as the plot in my GUI was empty (no value) when it should have been labeled 'axes1'. I believe in the process of the editing the GUIDE at one time, the Tag was changed unknowingly from 'axes1' to an empty string ('') and saved and the next time that I opened the .fig in GUIDE the dialogue box regarding colorbar started to appear, warning that if I save colorbar will no longer be supported.
Essentially the solution that worked for me (pointed out by Matlab Tech Support) was to open the .fig in GUIDE, ignore the dialogue box (Click Ok) then go to the object and fill out the Tag for the object with its original name before it was (unknowingly) rewritten; in my case, the name 'axes1'


Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 28 Sep 2020 at 21:16
this dialogue only appears when I open the .fig file in GUIDE (i.e. right clicking on the file in Matlab environment and selecting Open In GUIDE)
Don't Do That.
GUIDE-created .fig files are designed to only be opened from within the corresponding .m file. The .m file initializes the environment and then opens the .fig file and the .fig file needs the environment to have been initialized.


Show 3 older comments
Adam Danz
Adam Danz on 29 Sep 2020 at 14:27
If you can't attach the m & fig files, our hands are tied.
Steven Lord
Steven Lord on 29 Sep 2020 at 14:46
At this point, I agree with Adam Danz: I think further investigation is going to require seeing the figure and code files for this GUI. If you don't want to or can't post them on Answers, please contact Technical Support directly (using the telephone icon in the upper-right corner of this page) and ask the Support staff for assistance with this issue.
Sean Tosin
Sean Tosin on 29 Sep 2020 at 15:04
I'll contact technical support directly then and see if the issue can be resolved and provide the solution here if I am able. Thanks for all your help so far!

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!