MATLAB 如何绘制半透明的曲线?如何控制透明度?

87 Ansichten (letzte 30 Tage)
MathWorks Support Team
MathWorks Support Team am 18 Okt. 2019
MATLAB 如何绘制半透明的曲线?如何控制透明度?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 12 Sep. 2021
Bearbeitet: MathWorks Support Team am 30 Dez. 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

Weitere Antworten (0)

Kategorien

Mehr zu Scatter Plots finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!