use "set" with trasparent color

조회 수: 6 (최근 30일)
shamal
shamal 2025년 6월 6일
댓글: Walter Roberson 2025년 6월 7일
selected = findobj(allLines,'Type','line','LineWidth',0.5);
set(selected, 'MarkerFaceAlpha',.2,'MarkerEdgeAlpha',.2);
Error using matlab.graphics.chart.primitive.Line/set
Unrecognized property MarkerFaceAlpha for class Line.
Error in mycallback (line 19)
set(selected, 'MarkerFaceAlpha',.2,'MarkerEdgeAlpha',.2);
Error while evaluating Line ButtonDown
Hi, i try to color in trasparente mode but i get error

채택된 답변

Matt J
Matt J 2025년 6월 7일
편집: Matt J 2025년 6월 7일
It's undocumented, I believe, but you can control line transparency by setting the Color property to a 4-element RGBA value.
h=plot(rand(5,2),'r', 'LineWidth',4);
set(h(2),'Color',[1,0,0, 0.2]);
  댓글 수: 3
Matt J
Matt J 2025년 6월 7일
편집: Matt J 2025년 6월 7일
What I gave you in my example does precisely that. Both lines in the plot are red, but the second line has transparency alpha=0.2. That's what a transparent red line looks like (on a white background).
Walter Roberson
Walter Roberson 2025년 6월 7일
Note:
If you serialize a plot (such as save and restore, or send it between parallel workers), then the transparancy set in this manner will be discarded.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2025년 6월 7일
Line objects have never supported MarkerFaceAlpha or MarkerEdgeAlpha
MarkerFaceAlpha and MarkerEdgeAlpha are used for Scatter plots.
  댓글 수: 1
shamal
shamal 2025년 6월 7일
What do you recommend to make the plotted lines more transparent without changing the color?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by