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?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
% 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 comentarios
Respuestas (1)
Dyuman Joshi
el 16 de Abr. de 2023
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 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!