Pass plot parameters as a vector
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I can pass multiple vectors in a single call to plot
x = linespace(0,1000,10)
y(1,:)= exp(x);
y(2,:) = log(x);
y(3,:) = x.^2;
plot(x',y');
and this works. How can I also pass in properties for each plot in a single call? I've tried numerous variations of
colors = ['b','g','r'];
plot(x',y', colors');
but I always get errors
0 comentarios
Respuestas (1)
Voss
el 12 de Mzo. de 2023
x = linspace(0,1,10); % I changed the domain so you can see the lines
y(1,:)= exp(x);
y(2,:) = log(x);
y(3,:) = x.^2;
colors = 'bgr';
Option 1: plot(x1,y1,linespec1,x2,y2,linespec2,...)
figure
plot(x,y(1,:),colors(1),x,y(2,:),colors(2),x,y(3,:),colors(3));
Option 2: plot(x,y,linespec) in a loop
figure
hold on
for ii = 1:size(y,1)
plot(x,y(ii,:),colors(ii));
end
Option 3: h = plot(x,y); then set colors
figure
h = plot(x,y.');
set(h,{'Color'},num2cell(colors.'))
0 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!