I want to plot a transparent triangle

3 ビュー (過去 30 日間)
Pallov Anand
Pallov Anand 2023 年 9 月 23 日
編集済み: Bruno Luong 2023 年 9 月 23 日
I have the coordinates for the triangle, and I want to plot a triangle. I have been doing like this.
W = 0.5;
L = 0.3;
Patch = [-0.3, -W/2; -0.3, W/2; L, 0];
triangle_local = Patch;
triangle_handle = fill(triangle_local(:, 1), triangle_local(:, 2),'green');
With the above command, I am getting a triangle filled with green color. I want to get a transparent triangle, because I want to plot a point inside the triangle. How can I get a transparent triangle?

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 9 月 23 日
編集済み: Dyuman Joshi 2023 年 9 月 23 日
Use the color 'white'
W = 0.5;
L = 0.3;
Patch = [-0.3, -W/2; -0.3, W/2; L, 0];
triangle_local = Patch;
triangle_handle = fill(triangle_local(:, 1), triangle_local(:, 2),'white');
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 9 月 23 日
or set 'FaceColor' to 'none' for any color -
W = 0.5;
L = 0.3;
Patch = [-0.3, -W/2; -0.3, W/2; L, 0];
triangle_handle = fill(Patch(:, 1), Patch(:, 2),'green','FaceColor','none');

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

その他の回答 (1 件)

Bruno Luong
Bruno Luong 2023 年 9 月 23 日
編集済み: Bruno Luong 2023 年 9 月 23 日
Semi transparent, set FaceAlpha from 0 (100%transparent) to 1 (opaque)
W = 0.5;
L = 0.3;
Patch = [-0.3, -W/2; -0.3, W/2; L, 0];
plot3([0 0], 0.3*[-1 1], -0.1+[0 0], 'k', 'Linewidth', 2)
hold on
fill(Patch(:, 1), Patch(:, 2),'green','FaceAlpha',0.2)
axis equal

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by