简体   繁体   中英

Plot data behind 2D plot in Matlab

I have a fairly complex plotting problem that i thought it would be interesting to get a solution to. Say i have two plots, number 1:

This plot was created using plotyy.

And number 2:

This plot was created using plot3(x, y, z, '.')

Now, the complex part is i want to take plot number 2, watermark it and put it behind plot number 1. Which would result in something like this:

Effectively what i want to show is that plot 1 is made from data that looks like plot 2. Now i haven't been able to find how to do this so it may not even be possible, but if it can be done then it would be a great tutorial to have on stack overflow!

You can do this but it will take some work to get the axes formatted so they look nice.

What you need to do is put one axes object on top of another axes ; however, to prevent the top axes from occluding the bottom one you need to set the 'Color' property of the top axes object to 'none' .

Here is an example script that generates something similar to what you are looking for

f = figure;
axes();
x = rand(100,3)*3 + 3;
plot3(x(:,1), x(:,2), x(:,3),'.');

axes('Color', 'none');
x = -5:5;
y = x.^2;
line(x,y, 'Color', 'r', 'LineWidth', 2);

Here is the resulting figure: 在此处输入图片说明

If you don't like how this works out you can try to project your 3D data into 2D and then draw that projection as an image behind your lines. Here is a link to a discussion about how you might go about creating the 2D projection.

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