connect marker with lines

3 次查看(过去 30 天)
Hi all!
I have to connect these markers with one line, how can i do? My version of Matlab is 2014a.
The code is:
%plot
for i=1:18
figure(1)
title('Temperatura Max','fontsize',20)
xlabel('n° sensore','fontsize',15)
ylabel('Temperatura [°]','fontsize',15)
plot(i,Max_Temp20(1,i),'.','color',rgb('red'),'MarkerSize',20)
hold on
plot(i,Max_Temp30(1,i),'.','color',rgb('green'),'MarkerSize',20)
hold on
plot(i,Max_Temp50(1,i),'.','color',rgb('blue'),'MarkerSize',20)
hold on
plot(i,Max_Temp60(1,i),'.','color',rgb('pink'),'MarkerSize',20)
hold on
plot(i,Max_Temp70(1,i),'.','color',rgb('cyan'),'MarkerSize',20)
hold on
plot(i,Max_Temp80(1,i),'.','color',rgb('orange'),'MarkerSize',20)
hold on
plot(i,Max_Temp90(1,i),'.','color',rgb('black'),'MarkerSize',20)
hold on
grid on
legend('20% potenza','30% potenza','50% potenza','60% potenza','70% potenza','80% potenza','90% potenza')
end
Thank you!
  1 个评论
Jiri Hajek
Jiri Hajek 2023-1-25
This is readily done using the plot function properly. Please look at the plot documentation.

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2023-1-25
You don't need all those hold on's, you just need one. Also don't use a for loop because that's plotting just one marker at a time and the plot function has no knowledge of what prior marker you want to connect the current one to. You need to plot a whole range of data at one time. I think this should work.
columnsToPlot = 1:18;
figure(1)
plot(i,Max_Temp20(1,columnsToPlot), '.-', 'Color',rgb('red'), 'MarkerSize',20)
hold on
plot(i,Max_Temp30(1,columnsToPlot), '.-', 'Color',rgb('green'), 'MarkerSize',20)
plot(i,Max_Temp50(1,columnsToPlot), '.-', 'Color',rgb('blue'), 'MarkerSize',20)
plot(i,Max_Temp60(1,columnsToPlot), '.-', 'Color',rgb('pink'), 'MarkerSize',20)
plot(i,Max_Temp70(1,columnsToPlot), '.-', 'Color',rgb('cyan'), 'MarkerSize',20)
plot(i,Max_Temp80(1,columnsToPlot), '.-', 'Color',rgb('orange'), 'MarkerSize',20)
plot(i,Max_Temp90(1,columnsToPlot), '.-', 'Color',rgb('black'), 'MarkerSize',20)
grid on
title('Temperatura Max','fontsize',20)
xlabel('n° sensore','fontsize',15)
ylabel('Temperatura [°]','fontsize',15)
legend('20% potenza','30% potenza','50% potenza','60% potenza','70% potenza','80% potenza','90% potenza')
hold off;

更多回答(1 个)

Rajeev
Rajeev 2023-1-25
You can use the '-' in front of the marker to join the points with a line. Example:
plot(i,Max_Temp30(1,i),'-o','MarkerFaceColor','green','MarkerSize',20)

类别

Help CenterFile Exchange 中查找有关 ANOVA 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by