MATLAB 如何绘制半透明的曲线?如何控制透明度?
93 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 18 Oct 2019
Modifié(e) : MathWorks Support Team
le 30 Déc 2021
MATLAB 如何绘制半透明的曲线?如何控制透明度?
Réponse acceptée
MathWorks Support Team
le 12 Sep 2021
Modifié(e) : MathWorks Support Team
le 30 Déc 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Scatter Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!