필터 지우기
필터 지우기

Legend displays labels with correct colors

조회 수: 5 (최근 30일)
Mark Reed
Mark Reed 2020년 7월 20일
답변: Star Strider 2020년 7월 20일
I have 10 arrays of data. Each array creates 10 lines (data: 181X10) on a plot in the same color using plot(freq(:,i),data(:,:,i),ss{i}, 'LineWidth', 3). This give me 10 groups of 10 lines on the plot with each group color specified by SS. SS is a cell array that specifies the color used for each set of 10 lines: ss = {'b', 'g', 'r', 'c', 'm', 'y', 'k', 'b--', 'g--', 'r--', 'c--', 'm--', 'y--', 'k--', 'b*--', 'g*--', 'r*--', 'c*--', 'm*--', 'y*--', 'k*--'}. this all is contained in a FOR loop from 1:10. Labels are contained in a cell array: mb = {'data1' 'data2' .....}.
For example the first array of data plots 10 lines all in blue, the second array plots 10 lines all in green and so on up to 10 arrays (last array is 'g--'). My issue is how do you get the legend to display the correct label and cooresponding color for each group of 10 lines for the 10 arrays so the plot, legend color and style match ?

답변 (1개)

Star Strider
Star Strider 2020년 7월 20일
See if the approach in When specifying the color of points, legend does not match works in your application.

카테고리

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

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by