drawing rectangle on surface plots

조회 수: 10 (최근 30일)
Ozlem
Ozlem 2011년 9월 5일
Hi,
I draw a rectangle on a surface plot with the rectangle command however only some part of the rectangle is displayed. What could be the problem with this?
subplot(1,2,2)
surface(c/20,b/20,dset2(120:180,1:s(1)), 'EdgeAlpha',0)
set(gca,'XTickLabel',[])
set(gca,'YTickLabel',[])
xlim([0 2.5]);
ylim([-1.5 1.5]);
hold on;
rectangle('Position',[0,-0.5,2,1],...
'LineWidth',2,'LineStyle','-')
daspect([1,1,1])
hold on;

답변 (1개)

Walter Roberson
Walter Roberson 2011년 9월 5일
rectangle() is a 2D object only, and is not certain to show up at all unless the viewpoint is from directly above or directly below.
There are other MATLAB handle-graphic objects that are 2D only as well, such as image objects; the same difficulty applies to them.
line and lineseries objects such as are produced by plot() can have this same difficulty if only X and Y was specified, but fortunately these line objects can be made 3D by set()'ing their ZData property to be non-empty.
If you need your shape to be visible at other angles, you need to draw it as a patch() or surface(). (For images, usually the easiest approach is to texture-map them on to a patch or surface object.)

카테고리

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