How to assign different colours to the "levels" of a cylinder
1 回表示 (過去 30 日間)
古いコメントを表示
Hello everyone,
As the title says, I need to specify different colours for the segments composing a cylinder.
I built my cylindric structure using this .m file on File Exchange:
since I needed the structure to have different radius for every level.
Now, I have a vector with some values (let's call it x). What I'd like to do is to assign some colours to these values (say, if a value is in a certain range, assign to it colour blue). Then, using the data in x, I'd like to specify for every level of the cylinder the corresponding colour information stored in x.
Hope to have been clear enough.
Any help would be appreciated.
17 件のコメント
採用された回答
Geoff Hayes
2014 年 7 月 17 日
If you are trying to associate levels to colours, then with your 14 levels, you could define a 14x3 matrix where each row is a colour given by an RGB value
colours = zeros(14,3);
colours(1,:) = [1 0 0]; % red
colours(2,:) = [0 1 0]; % green
colours(3,:) = [0 0 1]; % blue
colours(4,:) = [0.6784 0.8471 0.9020]; % light blue
etc.
The above is an example only. Now initialize C in such a way that each element is assigned a value from 1 through 14 (for each of the 14 levels) given the contents of Z. In your example, your first row of Z is all zeros. If all these correspond to the first level, then set
C(1,:) = 1;
In the second row of Z, all values are 2.3. If this corresponds to the second level, then set
C(2,:) = 2;
Do this for all rows of C.
Now to display the cylinder with the specified colours, do something like
figure;
surf(X,Y,Z,C);
colormap(colours);
colorbar;
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Orange についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!