how to place an annotation one level deeper?

2 views (last 30 days)
Hi,
I would like to place a small image into an annotation. It works if I don't choose a background color:
But I would like to set the background color to black (this makes the picture (i.e. the grayscale) invisible. So, how can I shift the annoation one level back or to shift the small image one layer up? Using FaceAlpha is not an option for me...
Thanks a lot
  2 Comments
Adam Danz
Adam Danz on 11 Jan 2021
Why not create an overlaying axes instead of an annotation pane?

Sign in to comment.

Accepted Answer

Cris LaPierre
Cris LaPierre on 11 Jan 2021
I'm not aware of a way to order the layers. I think my approach would probably be to add a black shape in the image under the annotation. The annotation will move if the figure is resized.
% Add black shape in specified location
bx = mapshape([3541660 3541900 3541900 3541660],[5492180 5492180 5492250 5492250],'Geometry','polygon');
mapshow(ax,bx,'FaceColor','k')

More Answers (1)

Harald von der Osten
Harald von der Osten on 11 Jan 2021
yes, of course, here is the code:
%% Plottet Magnetogramm von Königheim-Brehmen mit Beschriftung und Rahmen
clear all
close all
GK=imread('Graukeil.jpg');
[A,R] = geotiffread('Kombi1b.tif');
figure('Renderer', 'painters', 'Position', [10 10 1200 800])
mapshow(A,R)
ax = gca;
ax.XRuler.Exponent = 0;
ytickangle(90)
xlabel('Rechtswert [m]')
ylabel('Hochwert [m]')
axis equal;
set(gca,'FontSize',18)
set(gca,'FontWeight','Bold')
set(gca,'TickLength',[0 0]);
ax.XTick = [3540500 3540700 3540900 3541100 3541300 3541500 3541700 3541900 3542100]
ax.YTick = [5492159.5 5492359.5 5492559.5 5492759.5 5492959.5]
xticklabels({0 ,200, 400, 600, 800, 1000, 1200, 1400, 1600})
yticklabels({0 ,200, 400, 600, 800})
% unten
rectangle('Position',[3540500,5492159.5,200,10],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3540700,5492159.5,200,10],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3540900,5492159.5,200,10],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541100,5492159.5,200,10],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541300,5492159.5,200,10],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541500,5492159.5,200,10],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541700,5492159.5,200,10],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541900,5492159.5,23,10],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
% links
rectangle('Position',[3540500,5492159.5,10,200],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3540500,5492359.5,10,200],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3540500,5492559.5,10,200],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3540500,5492759.5,10,200],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3540500,5492959.5,10,4],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
% oben
rectangle('Position',[3540500,5492964.6,200,10],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3540700,5492964.6,200,10],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3540900,5492964.6,200,10],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541100,5492964.6,200,10],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541300,5492964.6,200,10],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541500,5492964.6,200,10],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541700,5492964.6,200,10],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541900,5492964.6,23,10],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
% rechts
rectangle('Position',[3541912.53,5492159.5,10,200],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541912.53,5492359.5,10,200],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541912.53,5492559.5,10,200],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541912.53,5492759.5,10,200],'FaceColor','k','EdgeColor','k',...
'LineWidth',1)
rectangle('Position',[3541912.53,5492959.5,10,4],'FaceColor','w','EdgeColor','k',...
'LineWidth',1)
%% Markierung
%
hold on
t=text(3541300,5492730,'Graben');
set(t,'Rotation',25,'Color','w','FontSize',16,'FontWeight','bold')
t=text(3541110,5492600,'Graben');
set(t,'Rotation',-62,'Color','w','FontSize',16,'FontWeight','bold')
%% LEGENDE
%
hold on
t=annotation('textbox','String',{'Dynamikbereich:','-5 nT 6 nT'},'FaceAlpha',0.2);
t.FontSize=14;
t.FontWeight='bold';
t.Color='w';
t.EdgeColor='w';
t.LineWidth=1;
%t.BackgroundColor='k';
t.Position=[0.775 0.2 .12 .05];
hold on
axes('position',[0.81 0.162 0.05 0.1],'units','normalized')
imshow(GK);
Please find all other files attached.
Thanks a lot

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!