Why is the legend in my MATLAB code showing only one color for all the items, even though the colors are different in the parallel coordinates graph?
3 ビュー (過去 30 日間)
古いコメントを表示
% Define colors for each alphaclass
colors = {[1 0 0], [0 1 0], [0 0 1], [1 0 1]}; % RGB values for red, green, blue, magenta
alphaClasses = repelem(1:4, numImages/4);
% Create a parallel coordinates plot for the projected images
figure;
for i = 1:length(alphaClasses)
line(1:numComponents, projectedImages(i,:), 'Color', colors{alphaClasses(i)});
end
xlabel('AB');
ylabel('CD');
title('Parallel Coordinates Plot of Projected Images');
legend('ab', 'cd', 'ef', 'gh', 'Location', 'northeast');
0 件のコメント
回答 (1 件)
Dyuman Joshi
2023 年 4 月 16 日
Because there is only one line in the plot, as the plot is getting overwritten in each iteration. You need to use the command
"hold on" to retain all the plots in the same figure.
figure
hold on
for i = 1:length(alphaClasses)
line(1:numComponents, projectedImages(i,:), 'Color', colors{alphaClasses(i)});
end
%use hold off after the loop if necessary
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!