Reputation: 6937
I have a colored contour plot which is interpolated from a set of data locations. I would like to show the data locations on top of the contour plot. For some reason, the colored contour plot always covers up the data locations when I plot them together. It does not matter which one I plot first.
Why is this? And how can I force the data points to be plotted on top?
EDIT: Here's a picture (There are also more points in the middle of the triangle):
Upvotes: 3
Views: 8793
Reputation: 12345
There are a few things to check in this situation. Sorry for repeating anything that you've already tried.
Make sure that hold on
has been set, so that you are actually plotting both datasets.
Try the different renderers available. That is, try the following, one at a time.
set(gcf,'renderer','opengl') set(gcf,'renderer','painters') set(gcf,'renderer','zbuffer')
Note that there are other trades between these rendering options. For example, I suspect that 'painters' may provide the best render, but it will be very slow to update, and nearly impossible to (for example) rotate.
This is kind of a long shot, but try simply making your markers bigger. That is, replace
plot3(xdata, ydata, xdata, '.')
with
plot3(xdata, ydata, zdata, '.', 'markersize', 50)
If this is a 2D plot (I see from your edit that it is), then you can use the third dimension to force the correct order. All 2D items are actually plotted in 3D, with Z=0. Therefore if you want your markers to plot above the surface, you can replace:
plot(xdata, ydata, 'o')
with
plot3(xdata, ydata, 0.1, 'o')
Surfaces and lines are considered very different items b Matlab and the interlying graphics system. Ordering these different sorts of items sometimes requires a bit of help.
Upvotes: 6