Different color for each line

4 次查看(过去 30 天)
I would lilke to get for each line a different color.
the table features by 10 columns and 20 rows.
new_table = [t1 medienews]
plot(new_table{1, 2:end}', new_table{2:end, 2:end}',"LineWidth",2,'color',);
legend(new_table.t1{2:end}, 'location', 'eastoutside')
  2 个评论
KSSV
KSSV 2022-4-13
Simple question....read about plot.
Rachele Franceschini
编辑:Rachele Franceschini 2022-4-13
Yes, of course, as result I have 20 line with different color, but it is not for everyone. For eaxample I would like after red another color, not blue again (see LAZ and then LIG, as well as SAR and SIC)

请先登录,再进行评论。

采纳的回答

Chunru
Chunru 2022-4-13
% generate some random data
x = rand(10, 20);
% Generate different colors
cmap = jet(20);
% Change the colororder
colororder(cmap);
plot(x)
legend(string(1:20), "Location", "eastoutside")
  2 个评论
Stephen23
Stephen23 2022-4-13
编辑:Stephen23 2022-4-13
For distinguishable colors you will need to use a more suitable colormap, e.g. TAB20 here:
or perhaps generate your own colormap to suit your document colorscheme:

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Color and Styling 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by