MATLAB 如何绘制半透明的曲线?如何控制透明度?
238 views (last 30 days)
Show older comments
MathWorks Support Team
on 18 Oct 2019
Edited: MathWorks Support Team
on 30 Dec 2021
MATLAB 如何绘制半透明的曲线?如何控制透明度?
Accepted Answer
MathWorks Support Team
on 12 Sep 2021
Edited: MathWorks Support Team
on 30 Dec 2021
基本的plot函数不支持半透明,但可以使用scatter函数,且可以分开控制标记填充和标记边界的透明度。参考代码:
scatter1 = scatter(x,y,'MarkerFaceColor','r','MarkerEdgeColor','k');
% Set property MarkerFaceAlpha and MarkerEdgeAlpha to <1.0
scatter1.MarkerFaceAlpha = .2;
scatter1.MarkerEdgeAlpha = .2;
或者
scatter1 = scatter(x,y,'MarkerFaceColor','r','MarkerEdgeColor','k');
alpha(scatter1,.2)
如果想要使用plot绘制透明标记,可以参考代码:
plot(x,y);
hold on
scatter1 = scatter(x,y,'MarkerFaceColor','r','MarkerEdgeColor','k');
scatter1.MarkerFaceAlpha = .2;
hold off
如果需要对plot的线设置为半透明,参考代码:
plot1 = plot(x,y);
plot1.Color(4) = 0.2;
更多说明请参考:
https://www.mathworks.com/help/matlab/ref/alpha.html?#buvaucs-5
0 Comments
More Answers (0)
See Also
Categories
Find more on 曲面图和网格图 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!