How fill color for base load, peak load, intermediate load?

조회 수: 1 (최근 30일)
Pengshan Dai
Pengshan Dai 2019년 7월 9일
답변: Jyotsna Talluri 2019년 7월 25일
My data is with x axis date time, and y axis power in watt. They are data points.
I want to fill color for base load, peak load, intermediate load. Base load area should be from y=0 to y=3, and intermediate load is from y=3 to y=9, peak load is from y=9 to upper y value. I have tried the code below. But the green part is wrong. green part should be on the left and below blue part.
figure(1);
plot(myDatetime,PSummesplit,'b')
hold on;
le1=3.12;
le2=9;
area(myDatetime,max(PSummesplit, le1),le1,'EdgeColor','none','FaceColor',[0 0.25 0.25])
area(myDatetime,max(PSummesplit, le2),le2,'EdgeColor','none','FaceColor',[0 0.25 0.5])
How should I fix this? Can anyone help me out please? Thank you for your time!
  댓글 수: 1
Jyotsna Talluri
Jyotsna Talluri 2019년 7월 17일
Hi,
The code you implemented looks correct.It depends on the data of our plot.Can you provide the dataset (myDateTime,,PSummesplit)so that I can verify

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

채택된 답변

Jyotsna Talluri
Jyotsna Talluri 2019년 7월 25일
Hi,
The issue is that the base value of the first area is changing when the second area is displayed when using area() function.
Try implementing the below code which involves fill() function
Hope it works!
f1=PSummesplit>=1e1;
b1=1e1*ones(size(myDatetime(f1));
f2=PSummesplit>=1e2;
b2=1e2*ones(size(myDatetime(f2));
ph=funcfill(x(f),y(f),b2,[0 0.25 0.25] ,'none');
hold on;
ph=funcfill(x(f2),y(f2),b3,[0 0.25 0.5],'none');
function fillhandle=funcfill(xpoints,upper,lower,color,edge) %xpoints refer xvalues, upper corresponds to upper curve values,
% lower corresponds to lower curve values
filled=[upper,fliplr(lower)];
xpoints=[xpoints,fliplr(xpoints)];
fillhandle=fill(xpoints,filled,color);
set(fillhandle,'EdgeColor',edge,'FaceColor',color);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by