user2225930
user2225930

Reputation: 433

How to plot data points on top of what was previously plotted in MATLAB?

How to plot data points on top of what was previously plotted in MATLAB?

For example I have a 2D plot of a plane and points, and I plot the points with scatter3 after I plot the plane with pcolor, and the plane covers the points that are below it.

In the first image you can see the points by themselves. But when I plot them together with the plane, the plane covers the points below it.

enter image description here

enter image description here

THanks

Upvotes: 2

Views: 4774

Answers (3)

Dan
Dan

Reputation: 45752

The issue is that you are using scatter3 instead of scatter and it is plotting against the 3rd dimension linearly which is why the points disappear half way down. They are actually just behind your plane.

Upvotes: 2

Alexey
Alexey

Reputation: 5978

Use uistack to bring data points on top of the plot of the plane. Something like

p1 = plot(...); % plot of data points (need to be on top of plane) 
hold on;
p2 = plot(...); % plot of the plane

uistack(p1);  % to bring data points on top of the plane

Upvotes: 1

am304
am304

Reputation: 13876

Try hold on. See http://www.mathworks.co.uk/help/matlab/ref/hold.html for more information.

Upvotes: 0

Related Questions