Generating a Legend for Colormap
34 views (last 30 days)
Show older comments
I have several lines plotted on one graph that are color-coded by a colormap. I want to add a legend (not colorbar) that idenitifies each of the lines by their color. The colormap is working and the legend is generated, by the markers in the legend are all black. Here is what I have
cm = jet(size(x_mtx))
for i=1:size(x_mtx)
p3=plot(x_mtx(i,:), 'Color',cm(i,:));
hold on;
leg_label(i,:) = sprintf('%1.2e',rmse_mtx(i,1));
end
leg=legend(leg_label);
How can I color the legend with the color corresponding to the line plotted?
0 Comments
Answers (1)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!