Legend displays labels with correct colors

5 次查看(过去 30 天)
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