How to plot a filled box?

32 次查看(过去 30 天)
Stephan
Stephan 2017-12-5
评论: Stephan 2017-12-6
Hello everyone,
in 2 dimensions I can plot a shaded rectangle with the following code:
h=fill([0,1,1,0],[0,0,2,2],'red');
h.FaceAlpha=0.3;
My question is, how to do the same thing in 3 dimensions (with height=1). Then a rectangle would be a box.
Thanks, Stephan

采纳的回答

Jos (10584)
Jos (10584) 2017-12-5
Plot each of the sides separately
h = fill3([1 1 2 2],[1 2 2 1],[1 1 1 1],'r', ...
[1 1 2 2],[1 2 2 1],[2 2 2 2],'r', ...
[1 1 1 1],[1 2 2 1],[1 1 2 2],'b', ...
[2 2 2 2],[1 2 2 1],[1 1 2 2],'b', ...
[1 1 2 2],[1 1 1 1],[1 2 2 1],'g-',...
[1 1 2 2],[2 2 2 2],[1 2 2 1],'g-') ;
set(h,'FaceAlpha',0.3) ;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by