Legend displays labels with correct colors
3 views (last 30 days)
Show older comments
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 ?
0 Comments
Answers (1)
Star Strider
on 20 Jul 2020
See if the approach in When specifying the color of points, legend does not match works in your application.
0 Comments
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!