Multiple Views in same figure.

조회 수: 14 (최근 30일)
jaykrushna Patel
jaykrushna Patel 2017년 10월 13일
댓글: Walter Roberson 2018년 9월 15일
I am working on the project which creates a 3D plot as shown in the figure. I know about View() command to switch between the view. So I can plot 3D plots and 2D plots in XY and YZ plane. But is there any way that I can add all three views in the same figure?
<<
>>
I want all 3 outputs in the same figure. My final aim is to create an animation. So I don't want to plot everything 3 times as the subfigure.
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 9월 15일
Basically, plot something, invoke the rotation tool, grab it and start moving. The current view will be displayed interactively on the plot (and will probably stop being displayed when you release the mouse.) When you are satisfied,
[p,q] = view()
and read off the p and q values, and insert them in your code in the form
view([p,q])

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2017년 10월 14일
To display 2D graphics combined with 3D graphics, you need to do one of these things:
  • when possible, if there is a 3D equivalent to the 2D routine you used for the plotting, use the 3D equivalent and set the Z to a constant matrix of appropriate value. This in itself only works for data that is to be shown aligned with the X/Y plane, but can be combined with the below; or
  • parent the 2D graphics to a hgtransform and set the transform matrix to move and rotate it to the desired 3D position; or
  • for images, create a surf or patch that uses texture-mapping to display onto a flat surface in 3D. This is required if you want to rotate an image out of the X-Y plane: images are 2D objects that if you hgtransform will disappear showing only their edge.
  댓글 수: 4
Walter Roberson
Walter Roberson 2017년 11월 3일
main_ax = subplot(2,5,[1 2 3 4 6 7 8 9]);
sideax1 = subplot(2,5,5);
sideax2 = subplot(2,5,10);
axes(main_ax)
... do your drawing ...
ac = get(main_ax, 'Children'); %no hidden objects
copyobj( ac, sideax1 );
set(sideax1, 'xlim', ..., 'ylim', ...', 'zlim', ...)
view(sideax1, alt1, ax1 )
xlabel(sideax1, ...)
ylabel(sideax1, ...)
zlabel(sideax1, ...)
title(sideax1, ....)
copyobj( ac, sideax2 );
set(sideax2, 'xlim', ..., 'ylim', ...', 'zlim', ...)
view(sideax2, alt2, ax2 )
xlabel(sideax2, ...)
ylabel(sideax2, ...)
zlabel(sideax2, ...)
title(sideax2, ....)
Walter Roberson
Walter Roberson 2018년 9월 15일
Note: warp() is useful for images.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by