简体   繁体   中英

How do I add 2 Y axis to my MATLAB Plot?

I know this question has been asked before - but none of them deal with a 3D plot with 2 Y axis. My question is a continuation of - How do I add a 2D Plot along with a surface or mesh plot in MATLAB? or this .

I have now successfully managed to add a 2D plot along with a surface plot. See image below - 2D + 3D图 Now my problem is that the range of the 2D plot is so high that the 3D plot is shrunk to look like nothing more than a plane on the ceiling. It is supposed to have variations like the figure in the question I have lined above.

How do I provide a different Y axis for the 2D plot so that the 3D plot is not shrunk like it is here.

It's possible that you can use the DataAspectRatio property to accomplish this. Taking inspiration from the example from the previous post, if we have:

 z=peaks(100);
 x1=linspace(0,100);
 plot3(x1,0*ones(1,numel(x1)),40*sin(x1))
 surface(z+40, 'edgecolor', 'none');

and then you can use

set( gca, 'dataaspectratio', [1.25 1.25 .7] )
view( [-37.5 18] )

can work in some cases to help regain some of the range on the surface plot. This method won't work, however, in very extreme cases.

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