if trueclear allclose allclcx = datetime(2017,01,01):datetime(2017,01,20);y = [1,2,5,6,4,9,2,5,3,7,8,2,9,5,5,4,4,4,5,6];x1 = datetime(2017,01,05);x2 = datetime(2017,01,15);area(x,y,0,'LineStyle','-','EdgeColor','g','EdgeAlpha',0.4,'FaceColor','g','FaceAlpha',0.4)hold on%create area on the graph to mark specific areas
yVal = ylim; %allows to fill all the y area
y1 = [yVal(1),yVal(2),yVal(2),yVal(1)]; %create variable which allows to fill all the y area whith fill fonction
fill([x1 x1 x2 x2],y1,'','LineStyle','none','FaceColor','y','FaceAlpha',0.5) %fill an area on the graph for x1/x2
end
MATLAB: Using datetime data for x axis, I have an area plot on the whole x axis and I create a fill area for [x1 x2] to highlight a specific part of the graph. Fill created is over area plot and modifies its color. So how can I have fill plot in background
1
Related Question
- How to reshape the x-axis in this case
- How to fill the area or create a patch object between two lines in a plot in MATLAB R2016a
- Color background between two ylines patch (datetime)
- Graphing a system of equations on the same set of axes in 3d? please
- I’m trying to call patch without permanently changing the X axis from a datetime array.
Best Answer