How to plot a filled box?
19 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!