Filling area with pattern
Show older comments
Hello all,
I would like to know the how to fill the area with some pattern [CrossedLines, DiagonalLines, FDiagonalLines, HorizontalLines, Solid, VerticalLines, or XCrossedLines]. I already use this code to fill the area with color:
a=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]
sh2=stairs(1:24,a, '*','color',[0 1 0],'MarkerEdgeColor','r', 'MarkerSize',4,'LineWidth',1.3);
x = [sh2.XData(1),repelem(sh2.XData(2:end),2)]; % Although it works fine for me but I don't what is [XData(2:end),2] means, it would be good if you explain a bit.
y = [repelem(sh2.YData(1:end-1),2),sh2.YData(end)];
viu=fill([x,fliplr(x)],[y,bottom*ones(size(y))],[0 1 0])
viu.FaceAlpha = 0.2;
Accepted Answer
More Answers (0)
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!