How fill color for base load, peak load, intermediate load?
1 回表示 (過去 30 日間)
古いコメントを表示
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])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/228217/image.png)
How should I fix this? Can anyone help me out please? Thank you for your time!
1 件のコメント
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
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!