How do I use Transparency corretly in a GUI plot ??

2 views (last 30 days)
Hi guys
Im trying to put a picture of a compass as a background in my GUI plot. The GUI plot is made of subplots and each subplot has a x and y label. When I use "set(hi,'Alphadata',.4)" function to get transparency the titles flips (See attached picture), but if I save the figure in JPEG the title is correct? Its very weird! Can you help me? The code is like this:
% --- Executes on button press in wavespec.
function wavespec_Callback(hObject, eventdata, handles)
% hObject handle to wavespec (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
SR=evalin('base','SR_we');
Sp_we=evalin('base','Sp_we');
omega=evalin('base','omega');
%k={'North-West','North','North-East','West','','East','South-West','South','South-East'};
for j=1:length(SR) %Number of fields & SR
figure
% This creates the 'background' axes
ha = axes('units','normalized', ...
'position',[0 0 1 1]);
% Move the background axes to the bottom
uistack(ha,'bottom');
% Load in a background image and display it using the correct colors
% The image used below, is in the Image Processing Toolbox. If you do not have %access to this toolbox, you can use another image file instead.
I=imread('compass.jpg');
hi = imagesc(I);
colormap gray
% Turn the handlevisibility off so that we don't inadvertently plot into the axes again
% Also, make the axes invisible
set(ha,'handlevisibility','off', ...
'visible','off')
% Now we can use the figure, as required.
% For example, we can put a plot in an axes
axes('position',[0.3,0.35,0.4,0.4])
for i=[1:4 6:9] %Creating row x collums for subplot and number of headings
subplot(3,3,i)
plot(omega,Sp_we(:,1:length(i),j))
xlabel('\omega [rad/s]')
ylabel('S(\omega)')
end
suptitle(['Wave spectrum for area ', num2str(SR(j))])
% this creates transparency, you probably dont need it:
set(hi,'Alphadata',.4)
% move the image to the top:
uistack(ha,'top');
end
Thanks...

Answers (0)

Categories

Find more on 3-D Scene Control 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!