get alpha (color) value of a line

7 ビュー (過去 30 日間)
Ali Hilo
Ali Hilo 2022 年 9 月 27 日
コメント済み: Rik 2022 年 9 月 27 日
i need to copy a line to another plot, the copied line have alpha color value (Transperency / grey visibility) :
when drawing the line I use :
>> plot(...,'Color',[Color_Vect , Alpha],'LineWidth',10)
Color_Vect : vector of the colors i.e. [ 1 0 0] . Alpha =0.2.
in another section, when i need to copy the line to another plot I want to extract the alpha value of the line to add it to the new line.
I've been searching in all the values of the Line handles but couldnt find any aplha value.
do anyone knows were is this value stored ??
Thank you

採用された回答

Rik
Rik 2022 年 9 月 27 日
編集済み: Rik 2022 年 9 月 27 日
I have no clue why this is hidden, but converting the object to a struct and hunting for a few appropriate candidates I found that h.Edge.ColorData was a 4x1 uint8.
h=plot(rand(1,10),1:10,'Color',[1 0 0 0.2],'LineWidth',10);
warning('off','MATLAB:structOnObject')
h_=struct(h);h_.Edge.ColorData ,close
Warning: The LineSmoothing property will be removed in a future release.
Warning: The EraseMode property is no longer supported and will error in a future release.
ans = 4×1
255 0 0 51
Note that this is undocumented, and may be specific to a release and/or OS. This works on my Windows copy, as well as online, but it might only work for R2022b, you'll have to test this on R2019a yourself. Just look for anything that might fit after converting the object to a struct.
  2 件のコメント
Ali Hilo
Ali Hilo 2022 年 9 月 27 日
thank you Rik, it's working now and i can extract this value
Rik
Rik 2022 年 9 月 27 日
You're welcome.
I did a quick test, and it appears this works on R2020b and later (at least on Windows).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by