简体   繁体   中英

Put line object on top in MATLAB

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):

在此输入图像描述

There are a few things to check in this situation. Sorry for repeating anything that you've already tried.

  1. Make sure that hold on has been set, so that you are actually plotting both datasets.

  2. 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.

  3. 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)

  4. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM