Different color for each line

조회 수: 1 (최근 30일)
Rachele Franceschini
Rachele Franceschini 2022년 4월 13일
댓글: Rik 2022년 4월 13일
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일
편집: 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:
Rik
Rik 2022년 4월 13일
comment posted as flag by @Rachele Franceschini:
good tips

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by