Reputation: 141
Currently I am working on a matlab GUIDE and would like to include an image as the background of the GUI. May I know how can I include a static image in the GUI?
Upvotes: 1
Views: 18637
Reputation: 41
There is one another way of doing this.
Go to
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
function and right between handles.output = hObject;
and
guidata(hObject, handles);
write down the following code
% create an axes that spans the whole gui
ah = axes('unit', 'normalized', 'position', [0 0 1 1]);
% import the background image and show it on the axes
bg = imread('your_image.jpg'); imagesc(bg);
% prevent plotting over the background and turn the axis off
set(ah,'handlevisibility','off','visible','off')
% making sure the background is behind all the other uicontrols
uistack(ah, 'bottom');
Upvotes: 3
Reputation: 20915
You should use axes
graphical control:
f= figure()
a = axes('Position',[0 0 1 1],'Units','Normalized');
imshow('peppers.png','Parent',a);
You can put anything you want above the axes:
uicontrol('Style','text','Units','Normalized','Position',[0.1 0.1 0.3 0.6],'String','Example');
You can do it in GUIDE as well, simple stretch an axes over the whole figure manually.
Upvotes: 3