How to draw a number of colors from custom colormap?

9 ビュー (過去 30 日間)
Marcel345614
Marcel345614 2021 年 9 月 2 日
コメント済み: Marcel345614 2021 年 9 月 2 日
I used the colormapeditor to change a predefined colormap the way I want it. Then I saved this custom colormap to the workspace. It is a 256x3 vector.
How can I now draw a number of colors from this colormap?
Example:
I want 14 different colors for a plot with 14 lines.
In case of predefined colormaps, this would be easy:
cc=jet(14)
figure
hold on
plot(x,y,cc(:,1))
plot(x,y,cc(:,2))
...
How can I do the same thing with my custom colormap?

採用された回答

Jan
Jan 2021 年 9 月 2 日
編集済み: Jan 2021 年 9 月 2 日
YourMap = rand(256, 3);
% 14 color which exist in the original map:
Map14 = YourMap(round(linspace(1, 256, 14)), :);
% With interpolation:
Map14i = interp1(1:256, YourMap, linspace(1, 256, 14))
  1 件のコメント
Marcel345614
Marcel345614 2021 年 9 月 2 日
Thank you very much for your answer! It solves the problem!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by