allocating marker in for loop

4 visualizaciones (últimos 30 días)
H-M
H-M el 23 de Ag. de 2020
Respondida: Walter Roberson el 23 de Ag. de 2020
I tried to allocate a marker to each plot in for loop but I could'nt. would you please help me with that?
I was able to give each plot a disired color but for marker the error shows up.
Many thanks

Respuesta aceptada

Image Analyst
Image Analyst el 23 de Ag. de 2020
Try this:
markerShapes = {'.', 's', 'd', '^'}; % However many you need
for k = 1 : numPlots % numPlots must be less than the number of marker shapes.
thisColor = rand(3, 1); % Random color or whatever...
plot(x, y, markerShapes{k}, 'Color', thisColor);
hold on;
end

Más respuestas (1)

Walter Roberson
Walter Roberson el 23 de Ag. de 2020
N = 15;
x = 1 : 20;
y = rand(20, N);
cmap = parula(N);
for K = 1 : N
plot(x, y(:,K), 'color', cmap(K,:), 'DisplayName', string(K));
hold on
end
hold off
legend show

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by