How to represent two different quantities in the same 3d figure?

1 view (last 30 days)
Hi guys! Do you know how can I represent two 3d plots in the same figure, using two different z-axis?
Best!

Answers (2)

Walter Roberson
Walter Roberson on 26 Aug 2011
Sure, just use two axes() with overlapping Position values.
This is not something you should use subplot() for, as subplot() is designed for not overlapping the axes.
Note: if the two different plots need different color maps then you will need to do additional work.

Paulo Silva
Paulo Silva on 26 Aug 2011
One simple example:
x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
z1=2*sin(x1);
x2 = [1:.2:20];
y2 = x2.^2./x2.^3;
z2=20*sin(x2);
hl1 = line(x1,y1,z1,'Color','r');
ax1 = gca;
set(ax1,'XColor','r','YColor','r',...
'XTickLabel',{},'YTickLabel',{},...
'XTick',[],'YTick',[])
ax2 = axes('Position',get(ax1,'Position'),...
'Color','none',...
'XColor','k','YColor','k');
hl2 = line(x2,y2,z2,'Color','k','Parent',ax2);
view(ax1,30,30)
view(ax2,30,30)
zt2=get(ax2,'ZTickLabel');
zt1=get(ax1,'ZTickLabel');
set(ax2,'ZTickLabel',{},'ZTick',[])
set(ax1,'ZTickLabel',[zt1 blanks(size(zt1,1))' zt2])
Both x and y axes are common so they only appear once, I don't know how to move the z tick labels to the other side so I just put the labels side by side separated by a blank space.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!