how to place an annotation one level deeper?

조회 수: 12 (최근 30일)
Harald von der Osten
Harald von der Osten 2021년 1월 11일
댓글: Harald von der Osten 2021년 1월 11일
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
Cris LaPierre
Cris LaPierre 2021년 1월 11일
Could you share your images and your current plotting code for us to test with?
Adam Danz
Adam Danz 2021년 1월 11일
Why not create an overlaying axes instead of an annotation pane?

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 1월 11일
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')

추가 답변 (1개)

Harald von der Osten
Harald von der Osten 2021년 1월 11일
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

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by