Reputation: 71
Is it possible to erase an area of a plot, without direct manipulation of the data that you input to the plot (a posteriori)?
E.g. Area below y=x while the area above is kept.
Upvotes: 1
Views: 73
Reputation: 10440
Here's a way to do this by plotting only what is needed, and replace all other values with nan
:
[X,Y,Z] = peaks;
Z(X>Y) = nan;
contour(X,Y,Z,20)
Upvotes: 1
Reputation: 112679
You can use area
with white face color to blank the area of the plot below a given line:
t = linspace(0,20,500);
plot(t, sin(t)) % example plot
yl = ylim;
hold on
y = .4 - t * .05; % example limit line
area(t, y, yl(1), 'Facecolor', 'w', 'edgecolor', 'none');
Upvotes: 2