-2

I want to fill the area between d1 and d3, it makes it all, but the plot lines dissapiar after area command.

fGhz=[1;2;3;4;5;6;7;8;9;10];

d1 = ones(10,1)*(600e-6);
d2 = ones(10,1)*(2000e-6);
d3 = ones(10,1)*(300e-6);

plot(fGhz, lambdan_d10,'-ok',fGhz, d1, 'b',fGhz, d3, 'g',fGhz, d2, 'r','LineWidth',2)

%area([fGhz(1) fGhz(10)],[d1(1) d1(1)],d3(1), 'EdgeColor', 'none', 'FaceColor', [.7 .7 .7])    % plot a line between (x1,y1) and (x2,y2), then fill down to a baseline (6)
%ylim([0 7e-3]) 
Bobotic
  • 43
  • 1
  • 9

1 Answers1

0

It hard to deals with Your code without lambdan_d10 description. Nevertheless, I think it is not crucial for this question. I assume it as sine. Use rectangle function to fill this area:

% Your code
fGhz=[1;2;3;4;5;6;7;8;9;10];
lambdan_d10=sin(fGhz).*10^-2.5;
d1 = ones(10,1)*(600e-6);
d2 = ones(10,1)*(2000e-6);
d3 = ones(10,1)*(300e-6);
plot(fGhz, lambdan_d10)
plot(fGhz, lambdan_d10,'-ok',fGhz, d1, 'b',fGhz, d3, 'g',fGhz, d2, 'r','LineWidth',2)
% Fill area
XLIM=xlim();
rectangle('Position',[XLIM(1),d3(1),diff(XLIM),d1(1)-d3(1)],'FaceColor','y','EdgeColor','none')

In addition I would advice you to have some template for such reporting figures. My example:

%% >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
%% Parameters
fGhz = [1;2;3;4;5;6;7;8;9;10];
d1   = 600e-6;
d2   = 2000e-6;
d3   = 300e-6;
%% >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
%% Calculations
lambdan_d10 = sin(fGhz).*10^-2.5;
%% >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
%% Plot results
fig1 = figure();
hold all
% plot main information
plot(fGhz, lambdan_d10,'-ok','LineWidth',2);
% get plot parameters
XLIM = xlim();
% plot helpers
plot(XLIM,[d1 d1], '-b','LineWidth',2)
plot(XLIM,[d2 d2], '-r','LineWidth',2)
plot(XLIM,[d3 d3], '-g','LineWidth',2)
rectangle('Position',[XLIM(1),d3(1),diff(XLIM),d1(1)-d3(1)],'FaceColor','y','EdgeColor','none')
% annotation
xlabel('Hz')
ylabel('eggs')
title('lambda-spam')
zlon
  • 812
  • 8
  • 24