Fill between two lines not working

14 次查看(过去 30 天)
I am trying to fill the between the lines but its is only plotting the limiting lines. I cant seem to understand the problem.
Hope you can help. Thanks in advance.
figure(2)
semilogx((f_Along)*(0.1/WS),f_Along.*((PSD_AL_M))/WSP^2,'Color',...
'k','LineWidth',2)
hold on
semilogx((f_Along)*(0.1/WS),f_Along.*((SD_AL_P))/WSP^2,'Color',...
[0.7 0.7 0.7],'LineWidth',2,'DisplayName','STD+')
hold on
semilogx((f_Along)*(0.1/WS),f_Along.*((SD_AL_N))/WSP^2,'Color',...
[0.7 0.7 0.7],'LineWidth',2,'DisplayName','STD-')
hold on
x2 = [(f_Along')*(0.1/WS), fliplr((f_Along')*(0.1/WS))];
inBetween = [f_Along'.*((SD_AL_P'))/WSP^2, fliplr(f_Along'.*((SD_AL_N'))/WSP^2)]
fill(x2, inBetween, 'k');
hold on
  3 个评论
Walter Roberson
Walter Roberson 2020-4-10
It would be easier if we had your data so we could test on our own system to avoid accidentally giving you a solution that does not work for your situation.
Saugat Shrestha
Saugat Shrestha 2020-4-10
I have attached the variables.
Thanks in advance.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2020-4-9
Plot everything (including the patch calls) using linear axis rulers first, then convert the scale to logarithmic.
.
  8 个评论
Star Strider
Star Strider 2020-4-10
@Saugat Shrestha — It would have helped to have had your data at the outset. As Walter points out, the problem is that ‘f_Along’ begins with 0. Since log(0) appraches -Inf, the transformation fails for patch.
Add before you create ‘figure(2)’:
f_Along = f_Along + eps;
and after the patch (or fill) call:
xlim([f_Along(2) f_Along(end)])
set(gca, 'XScale','log')
@Walter — Thank you.
.
Saugat Shrestha
Saugat Shrestha 2020-4-11
@Walter Roberson, I did as you instructed and it worked.
Thank You so much.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by