Is there a difference between a uipanel created with GUIDE and a uipanel created with the function?
Show older comments
I am making a GUI with GUIDE that involves adding an axes and legend for the axes to a panel. My problem arises when I try to add interactive functionality to my legend, specifically the Toggle Chart Visibility functionality shown at this link https://www.mathworks.com/help/matlab/creating_plots/create-callbacks-for-interacting-with-legend-items.html.
In my GUIDE program, I create the axes with the parent specified as the uipanel:
handles.ax1 = axes('Parent', handles.uipanel1, 'NextPlot', 'add');
And then later, I add a contour and a legend for the contour to the axes with this process:
contour(handles.ax1, peaks, 'DisplayName', 'Peaks Contour');
obj_handle = findobj('DisplayName', 'Peaks Contour');
handles.leg = legend(handles.ax1, obj_handle);
set(handles.leg, 'ItemHitFcn', @hitcallback_ex1);
The hitcallback_ex1 function is the same as in the example that I linked above.
I have also tried this process in the command window creating a figure and uipanel without using GUIDE and then repeating the process:
f = figure;
panel1 = uipanel(f);
ax1 = axes('Parent', panel1, 'NextPlot', 'add');
contour(ax1, peaks, 'DisplayName', 'Peaks Contour');
obj_handle = findobj('DisplayName', 'Peaks Contour');
leg = legend(ax1, obj_handle);
set(leg, 'ItemHitFcn', @hitcallback_ex1);
And this works perfectly. My question is, what is causing the GUIDE program to behave differently than the code I wrote in the command window and how can I make my program behave the same way? I hope my question was clear enough and I am happy to provide any other information that can help solve this.
Thank You
Answers (0)
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!