フィルターのクリア

How do I translate RGB color to a color on my patch Object?

13 ビュー (過去 30 日間)
Abhay Aradhya
Abhay Aradhya 2017 年 6 月 7 日
コメント済み: Walter Roberson 2017 年 6 月 7 日
X = [0 0 5; 0 0 5; 4 4 9];
Y = [0 4 0; 3 7 3; 0 4 0];
C = [0; .2422; 1];
figure
patch(X,Y,C);
Can anyone please help me find out how this value "0.2422" translates to its corresponding RGB value.
Matlab Documentation (" https://www.mathworks.com/help/matlab/creating_plots/how-patch-data-relates-to-a-colormap.html ") is not of much use in this directtion as well.!!

採用された回答

KSSV
KSSV 2017 年 6 月 7 日
編集済み: KSSV 2017 年 6 月 7 日
X = [0 0 5; 0 0 5; 4 4 9];
Y = [0 4 0; 3 7 3; 0 4 0];
figure
mycolor = 'r' ; % you can use 'r','b','g','c','m','k', etc..
patch(X,Y,mycolor);
  1 件のコメント
Abhay Aradhya
Abhay Aradhya 2017 年 6 月 7 日
Thank you that worked. But I wanted the RBG values to the color being put in.
X = [0 0 5; 0 0 5; 4 4 9];
Y = [0 4 0; 3 7 3; 0 4 0];
figure
mycolor = [1 0.76 0]
patch(X,Y,mycolor);
This did the tric

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 6 月 7 日
Cdatamapping defaults to scaled. You end up about 1/4 of the way through the color map.
  2 件のコメント
Abhay Aradhya
Abhay Aradhya 2017 年 6 月 7 日
Walter found a way to get it done
X = [0 0 5; 0 0 5; 4 4 9];
Y = [0 4 0; 3 7 3; 0 4 0];
figure
mycolor = [1 0.76 0]
patch(X,Y,mycolor);
This will assign the same color to all the triangles in this case. If you need to assign different colors then just pass the "patch" line through a loop and assign different colors to it. You could make a array of colors if that helps and loop it through.
Walter Roberson
Walter Roberson 2017 年 6 月 7 日
This is a different question than what you asked. You were asking how MATLAB determined which color got plotted given a particular data value, not how to force a particular face or edge to be a particular color.

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

カテゴリ

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