2 axis plotting with different markers
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
uki71319
el 17 de Dic. de 2022
Dear all, i'm trying to plot 2 axis lines with the corresponding 5 different markers. But the code (commented one) always got errors.
Could anyone tell me how can i solve this issue???
Any help is greatly appreciated.
%plotting
% I want to plot two axis with different markers for Yleft(hollow marker)and Xleft (filled marker),
% different markers are connected with lines
rate=[5,10,15,20,25]
Yleft=[1.99,2.78,2.67,2.54,2.45]
d=plot(f,Yleft,'.-')
%plot(f(1),Yleft(1),'o',rate(2),Yleft(2),'*',rate(3),Yleft(3)','^',rate(4),Yleft(4),'square',rate(5),Yleft(5),'dimaond')
% d(1).Marker="o";
% d(2).Marker="*"
% d(3).Marker="^"
% d(4).Marker="square"
% d(5).Marker='diamond'
yyaxis left
title('Yleft and Xleft vs. z ')
xlabel('flow rate [m^3/s]')
ylabel('YLeft [W/m/K]')
yyaxis right
Xleft=[1070,695,636,680,758]
f=plot(rate,Xleft,'*-')
% f(1).Marker="o";
% f(2).Marker="*"
% f(3).Marker="^"
% f(4).Marker="square"
% f(5).Marker='diamond'
ylabel('XLeft [W/m^2/K]')
0 comentarios
Respuesta aceptada
Askic V
el 17 de Dic. de 2022
Editada: Askic V
el 17 de Dic. de 2022
I would do somthing like this:
%plotting
% I want to plot two axis with different markers for lambda_r (hollow marker)and alpha_w (filled marker),
% different markers are connected with lines
f=[5,10,15,20,25];
lam=[1.99,2.78,2.67,2.54,2.45];
d=plot(f,lam,'.-');
hold on
markers = {'o','*','^','square', 'diamond'};
for i = 1:numel(f)
plot(f(i),lam(i),markers{i});
end
yyaxis left
title('lambda\_r and alpha\_w vs. z ')
xlabel('flow rate [m^3/s]')
ylabel('lambda\_r [W/m/K]')
2 comentarios
Askic V
el 17 de Dic. de 2022
Editada: Askic V
el 17 de Dic. de 2022
Even though VBBV already posted, I'll answer to your questions regarding the color in the following way:
%plotting
% I want to plot two axis with different markers for lambda_r (hollow marker)and alpha_w (filled marker),
% different markers are connected with lines
f=[5,10,15,20,25];
lam=[1.99,2.78,2.67,2.54,2.45];
plot(f,lam,'b.--' )
hold on
markers = {'o','*','^','square', 'diamond','b'};
for i = 1:numel(f)
plot(f(i),lam(i),['b' markers{i}]);
end
yyaxis left
title('lambda\_r and alpha\_w vs. z ')
xlabel('flow rate [m^3/s]', 'Color', 'k')
ylabel('lambda\_r [W/m/K]', 'Color', 'b')
ax = gca;
set(ax, 'YColor', 'r')
yyaxis right
k_w=[1070,695,636,680,758]
plot(f,k_w,'r*--')
markers = {'o','*','^','square', 'diamond'};
for i = 1:numel(f)
d = plot(f(i),k_w(i),['r' markers{i}]);
end
ylabel('alpha\_w [W/m^2/K]', 'Color', 'r')
ax = gca;
set(ax, 'YColor', 'b')
Más respuestas (1)
Askic V
el 18 de Dic. de 2022
If you want to have legend only on points 'o' in both red and blue lines, I would do this:
%plotting
% I want to plot two axis with different markers for lambda_r (hollow marker)and alpha_w (filled marker),
% different markers are connected with lines
f = [5,10,15,20,25];
lam = [1.99,2.78,2.67,2.54,2.45];
plot(f,lam,'b.-' );
hold on
markers = {'o','*','^','square', 'diamond','b'};
for i = 1:numel(f)
d(i)= plot(f(i),lam(i),['b' markers{i}]);
end
yyaxis left
title('lambda\_r and alpha\_w vs. z ')
xlabel('flow rate [m^3/s]', 'Color', 'k')
ylabel('lambda\_r [W/m/K]', 'Color', 'b')
ax = gca;
set(ax, 'YColor', 'r')
yyaxis right
k_w=[1070,695,636,680,758];
plot(f,k_w,'r*--')
markers = {'o','*','^','square', 'diamond'};
for i = 1:numel(f)
h(i) = plot(f(i),k_w(i),['r' markers{i}]);
end
ylabel('alpha\_w [W/m^2/K]', 'Color', 'r')
legend([d(1) h(1)],'Point o blue','Point o red');
ax = gca;
set(ax, 'YColor', 'b')
Ver también
Categorías
Más información sobre Geometry and Mesh 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!