connect marker with lines

조회 수: 3 (최근 30일)
ANDREA
ANDREA 2023년 1월 25일
댓글: ANDREA 2023년 1월 25일
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에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by