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

1 visualización (últimos 30 días)
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 comentario
Jyotsna Talluri
Jyotsna Talluri el 17 de Jul. de 2019
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

Iniciar sesión para comentar.

Respuesta aceptada

Jyotsna Talluri
Jyotsna Talluri el 25 de Jul. de 2019
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

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by