Filter löschen
Filter löschen

add a shape to the figures in one plot

16 Ansichten (letzte 30 Tage)
mehra
mehra am 13 Okt. 2021
Beantwortet: Voss am 29 Dez. 2021
Hi guys
I want to add a shape to figures in one plot,
In fact I have the codes for a set of figures in the format of subplots but I want to put a shape in the same plot like the sketch I have inserted here (I can plot the figures by using subplot and I can plot the shape separately (rectangle or oval shown in black) but I want them to be like the sketch below)
My current codes are like:
figurem=4;
figure(figurem);
%rectangle('position',[-1,-0.5,1,1],'curvature',[1,1],'edgecolor','none','facecolor',[0.8
%0.8 0.8]) %%% This doesnt work
%hold on
for r_c=1:2
subplot(1,15,r_c)
plot(u_lat_con(:,r_c)./Uund,yler_D2,'r');
xlabel('$\overline{u}/U_0$','interpreter','latex')
ylabel('$y/D$','interpreter','latex')
title(sprintf('x/D=%.2f',xlerc(r_c)./D))
ylim([0 3.1133]);
xlim([-0.2 1.3]);
end
for r_w=1:13
subplot(1,15,r_w+2)
plot(u_lat_w(:,r_w)./Uund,yler_D1,'b',u_lat_w(:,r_w)./Uund,-yler_D1,'b');
xlabel('$\overline{u}/U_0$','interpreter','latex')
ylabel('$y/D$','interpreter','latex')
title(sprintf('x/D=%.2f',xler1(r_w)./D))
xlim([-0.2 1.3]);
ylim([-3.5 3.5]);
end
The commented line is the shape I want to add to the figures, and I want the plots to start from the right position as shown in the sketch.
Thanks in advance
  2 Kommentare
Image Analyst
Image Analyst am 13 Okt. 2021
The code doesn't plot anything for me. You forgot to include variables that would make it work. So I'm bailing out until then.
mehra
mehra am 13 Okt. 2021
I thought the variables wouldn't be necessary, since I need the code about inserting the shape just like the sketch.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Voss
Voss am 29 Dez. 2021
The first call to subplot() deletes the rectangle and the axes it was in, so that's why you don't see it when you run your code. You should create the rectangle after the relevant call to subplot() is made.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by