How can change transparency and thickness of a line in Matlab

68 ビュー (過去 30 日間)
amir nemat
amir nemat 2017 年 8 月 2 日
コメント済み: rui sun 2021 年 11 月 16 日
I have written the code in Matlab by using scatter. However, I cannot change alpha value or opacity, or transparency of the line. Can anyone guide how can I do it just by using scatter plot?
x=[1:140];
sz=1;
H=scatter(x(1),y(1),sz)
set(H,'MarkerFaceColor','blue');
set(H,'MarkerEdgeColor','blue');
hold on
for i=2:140
sz=sz+1;
H=scatter(x(i),x(i),sz)
set(H,'MarkerFaceColor','blue');
set(H,'MarkerEdgeColor','blue');
end
I have already tried the following code but it gave me error
set(H,'MarkerFaceAlpha',.2);
set(H,'MarkerEdgeAlpha',.2);
  1 件のコメント
Rik
Rik 2017 年 8 月 2 日
Can you show the entire error message? Because I just tried it in R2017a and I didn't get an error.

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

採用された回答

José-Luis
José-Luis 2017 年 8 月 2 日
Provided you have a reasonably recent version of Matlab:
p1 = plot(rand(10,1),'r-','LineWidth',5); hold on
p2 = plot(rand(10,1),'r-','LineWidth',2);
p1.Color(4) = 0.25;
p2.Color(4) = 0.75;
  6 件のコメント
Jiri Hrdlicka
Jiri Hrdlicka 2021 年 6 月 11 日
Same here, the undocumented 4-element color spec does not seem to work, anymore (R2021a).
rui sun
rui sun 2021 年 11 月 16 日
The color editing still works for me on 2021a.
data = randn(100,2);
hline = plot(data);
for i=1:length(hline)
hline(i).Color = [hline(i).Color 0.1]; % alpha=0.1
end

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by