MATLAB: Is it possible to draw a plot in a frame uicontrol in MATLAB

axesbackfigureframefrontgideguiMATLABplotuicontrol

I would like to draw a plot in a frame uicontrol in MATLAB. How can this be done using MATLAB 7.0 (R14)?

Best Answer

It is not possible to draw a plot on top of a frame uicontrol in MATLAB. However, it is possible to place axes objects on top of UIPANEL objects (which were introduced in MATLAB 7.0 (R14)).
It is not possible to display an axes on top of a frame uicontrol because the uicontrols are placed over the figure window rather than within the figure window. Therefore, the frame uicontrol will always be drawn on top of the axes.
If you are using a version of MATLAB prior to 7.0, or if you want to use a frame uicontrol with MATLAB 7.0 instead of a uipanel, you may want to create a second axes and set its color so that it is similar to the frame color.
For example:
figure;
h_frame = uicontrol('style','frame');
frame_color = get(h_frame,'BackGroundColor');
delete(h_frame)
ax_frame = axes('color',frame_color,'ytick',[],'xtick',[]);
box on;
ax_plot = axes('position',[.2 .2 .5 .6])
plot(1:10)